Hi,
I have ListBox on a UserForm that pre-loads items from a list ("TheList") and then pre-loads the already selected items on that list from another list ("TheListSelected"). It works perfectly except for one little thing. I would like to relocate the TheList to another sheet but the code uses CELL and OFFSET and I don't know how to get them to read from a range on another sheet.
I've attached the file, but the code I ned to change is pasted below in bold:
Private Sub UserForm_Initialize()
Dim cell As Range
'Define the list as a named range
With Sheets("HappySheet")
Application.Names.Add "TheList", .Range("A5", .Range("A" & Rows.Count).End(xlUp))
End With
CheckBox1.Value = True 'Default setting
With ListBox1
For Each cell In Range("TheList") ' Loop through each cell in the list
.AddItem cell.Value ' Add items to the ListBox
If cell.Offset(, 2).Value = cell.Value Then ' test if the item is in the Selected List
.Selected(.ListCount - 1) = True ' Select the item in the Listbox
Else
CheckBox1.Value = False ' Unheck the Select All checkbox one item is not selected
End If
Next cell
End With
End Sub
Is this just a small tweak of code?
Lawrence
Bookmarks