我构造了下面的代码,以便在工作表"MFGLR“的A列中找到combobox2值(如果有,如果不是,什么也不做),然后在与combobox2值相同的行中,将文本框的值粘贴到AE列中。我找不到如何让它正常工作。
背景:我有一个有2个组合框和1个文本框的用户表单。我已经创建了3个场景,对于其中2个场景,我需要上面所说的发生。
Sub linepick()
Dim N As Long
Dim i As Long
'Check for a row with combobox2 value and use that as a pointer to populate the textbox in that active row
N = Cells(Rows.Count, "A").End(xlUp).Row
For i = 5 To N
If Cells(i, "A").Value = Combobox2.value Then
'The = Combobox2.value brings up an error
Cells(i, "A").Rows.Select
End If
Next i
Userform2.Textbox1.text = CStr(Worksheets("MFGLR").Range("AE" & ActiveCell.Row).Value)
End Sub
如果我解释得不够充分,请告诉我。谢谢
发布于 2019-06-04 03:02:31
我想这就是你想要的。
Sub () Dim N as Long Dim I As Long‘检查具有工作表(“combobox2”)值的行并将其用作指针以填充活动行中的文本框N= Worksheets("MFGLR").Cells(Rows.Count,"A").End(xlUp).Row for i=5 to N If Worksheets("MFGLR").Cells(i,"A").Value =Userform2.Combox2Value Then Worksheets("MFGLR").Cells(i,"AE").Value = Userform2.Textbox1.Text Exit Sub Next I End子
https://stackoverflow.com/questions/56433036
复制相似问题