abdelfattah
Well-known Member
- Joined
- May 3, 2019
- Messages
- 1,507
- Office Version
- 2019
- 2010
- Platform
- Windows
Hello
in this part of my project will call this code from UserForm_Initialize() , also I have combobox1,2 also call this code from them
what I need it when populate data based on selected item from comboboxes . then should select item in list box automatically based on last highlighted cell by red color (there are many highlighted cells by red color, just I want select row in listbox automatically based on last cell is highlighted in column E)
every time will change last highlighted cell in location .
note: I want showing this selected item by moving above if the selected item is not visible(meaning I have to use scroll bar up to down to see it, I don't want it. I want automatically without interfere from me. this note is option if it's impossible just ignore it(I will post new thread to solve this note)
if anybody need the whole codes I will post , just inform me .
thanks
in this part of my project will call this code from UserForm_Initialize() , also I have combobox1,2 also call this code from them
what I need it when populate data based on selected item from comboboxes . then should select item in list box automatically based on last highlighted cell by red color (there are many highlighted cells by red color, just I want select row in listbox automatically based on last cell is highlighted in column E)
every time will change last highlighted cell in location .
note: I want showing this selected item by moving above if the selected item is not visible(meaning I have to use scroll bar up to down to see it, I don't want it. I want automatically without interfere from me. this note is option if it's impossible just ignore it(I will post new thread to solve this note)
VBA Code:
Private Sub LBoxPop()
Dim r As Long, c As Long
Dim Data() As Variant
Dim rng As Range
Set rng = ws.Cells(1, 1).CurrentRegion
ReDim Data(1 To rng.Rows.Count, 1 To rng.Columns.Count)
For r = 1 To UBound(Data, xlRows)
For c = 1 To UBound(Data, xlColumns)
Data(r, c) = rng.Cells(r, c).Text
Next c
Next r
With UserForm1.ListBox1
.ColumnCount = 5
.columnWidths = "80;240;120;120;120"
.List = Data
End With
End Sub
thanks
Last edited: