列表框 [英] list box
问题描述
我使用以下代码作为列表框。根据需要,它不起作用。我希望它只选择两行,一行是第3行中的标题,第二列是D4:D选择由COMBOBOX REPEATCASES选择,第二行也应该可以在列表框中编辑。然后我想要
它输入到下一个空行中的工作表。
如果列表框选择的第二行只有那些具有值且值为0的列,则应该更准确,以及它的标题。因为这个领域将有近200列,并且有价值,b $ b最多只有10或12。当输入到工作表时,此数据应该转到选择它的同一列,而不是转到其他列。
Private Sub RepeatCases_Change()
        '清除TextBox5中的文字
TextBox5.Value =""
Dim ws As Worksheet
Dim name As String
Dim c As Range
设置ws = ActiveWorkbook.Worksheets(" DATA")
I = ws.Range(" D"& ws.Rows.Count).End(xlUp).Row
如果RepeatCases.Value<> ""然后
name = RepeatCases.Value
'从E栏中找到所选值< b $ n 设置c = ws.Range(" D4:D& I).Find(name,LookIn:= xlValues,LookAt:= xlWhole)
如果Not c Is Nothing则为
'将J栏中的相关值设置为TextBox5
TextBox5.Value = ws.Range(" H" c.Row).Value
与我
ListBox1.Visible = True
'ListBox1.List = Range(" H4:ZZ"& Range(" D"& Rows.Count).End(xlUp).Row).SpecialCells(xlCellTypeConstants).Value
ListBox1.List = Range(" H3:ZZ"& Range(" A"& Rows.Count).End(xlUp).Row).Value
ListBox1.ColumnCount =""
结束
结束如果是
结束如果
结束子
谢谢,
请帮忙解决这个问题,
dockhem
$
我很清楚你的详细要求。
据我所知,ListBox的项目无法编辑。我们需要使用代码来修改数据。
要选择行,我们可以使用Selected Property。
我!Listbox.Selected(2)= True最好的问候
Starain
Hi,
I use following code for a list box. It does not work, as desired. I want it to select only two rows, one that of headings in row 3 and second next columns to D4:D selected by COMBOBOX REPEATCASES, also second row should be editable in list box.Then I want it to enter to work sheet in next empty row.
It will be more accurate if second row selected by list box has only those columns, which have values and with 0 value should be avoided along with it's headings. Because there are nearly 200 columns will be there in this field and with value there will be only 10 or 12 at the most. When entered to worksheet this data should go to same column from which it was selected and do not go to other column.
Private Sub RepeatCases_Change()
'clear the text in TextBox5
TextBox5.Value = ""
Dim ws As Worksheet
Dim name As String
Dim c As Range
Set ws = ActiveWorkbook.Worksheets("DATA")
I = ws.Range("D" & ws.Rows.Count).End(xlUp).Row
If RepeatCases.Value <> "" Then
name = RepeatCases.Value
'find the selected value from column E
Set c = ws.Range("D4:D" & I).Find(name, LookIn:=xlValues, LookAt:=xlWhole)
If Not c Is Nothing Then
'set the related value in J column to TextBox5
TextBox5.Value = ws.Range("H" & c.Row).Value
With Me
ListBox1.Visible = True
'ListBox1.List = Range("H4:ZZ" & Range("D" & Rows.Count).End(xlUp).Row).SpecialCells(xlCellTypeConstants).Value
ListBox1.List = Range("H3:ZZ" & Range("A" & Rows.Count).End(xlUp).Row).Value
ListBox1.ColumnCount = ""
End With
End If
End If
End Sub
Thanks,
Please help with this,
dockhem
Hi dockhem2,
I don’t understand clearly your detail requirement, please provide the screenshot to explain it.
As far as I know the item of ListBox can’t be editable. We need to use the code to modify the data.
To select the row, we could use Selected Property.
Me!Listbox.Selected(2) = TrueBest Regards
Starain
这篇关于列表框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!