Below is my code for listbox. My problem is that the listbox pulls information from the activesheet not the "CreditData" sheet. What is wrong with my code?
colcnt = Worksheets("CreditData").UsedRange.Columns.Count
rowcnt = Worksheets("CreditData").UsedRange.Rows.Count
Set rng = Worksheets("CreditData").Rows("2:" & rowcnt)
With ListBox2
.ColumnCount = 5
.RowSource = rng.Address
cw = ""
For c = 1 To .ColumnCount
cw = cw & rng.Columns(c).Width & ";"
Next c
.ColumnWidths = cw
.ListIndex = 0
End With
NL
colcnt = Worksheets("CreditData").UsedRange.Columns.Count
rowcnt = Worksheets("CreditData").UsedRange.Rows.Count
Set rng = Worksheets("CreditData").Rows("2:" & rowcnt)
With ListBox2
.ColumnCount = 5
.RowSource = rng.Address
cw = ""
For c = 1 To .ColumnCount
cw = cw & rng.Columns(c).Width & ";"
Next c
.ColumnWidths = cw
.ListIndex = 0
End With
NL