Hi,
Looking for some VBA help, this is probably very simple (hopefully ).
I have a form that allows user to select a worksheet from the current workbook using a combobox, the listbox will then display the contents of the selected worksheets header row (where row 1 is always the header). The listbox uses the following settings
Then within the listbox the user selects a number of columns from the chosen worksheet. I would like the columns selected in the listbox to also be selected in the worksheet. Ultimately I will be concatenating the data in the selected columns and looping through the worksheet looking for duplicates.
Here is the code I use to select the slected list box items, I need help in selecting the worksheet columns as a multi column range.
Any help would be greatly appreciated.
Many thanks
James
Looking for some VBA help, this is probably very simple (hopefully ).
I have a form that allows user to select a worksheet from the current workbook using a combobox, the listbox will then display the contents of the selected worksheets header row (where row 1 is always the header). The listbox uses the following settings
Code:
.ListStyle = fmListStyleOption
.MultiSelect = fmMultiSelectMulti
Then within the listbox the user selects a number of columns from the chosen worksheet. I would like the columns selected in the listbox to also be selected in the worksheet. Ultimately I will be concatenating the data in the selected columns and looping through the worksheet looking for duplicates.
Here is the code I use to select the slected list box items, I need help in selecting the worksheet columns as a multi column range.
Code:
Private Sub btGetFields_Click()
Dim iCtr As Long
Dim strSearch As String
strSearch = ""
With Me.lbxColumns
For iCtr = 1 To .ListCount - 1
If .Selected(iCtr) Then
[COLOR=red]' CODE REQUIRED HERE TO SELECT COLUMNS WHERE[B] .List(iCtr) = COLUMN HEADER[/B][/COLOR]
[COLOR=red]' EACH TIME THE PROCEDURE LOOPS AN ADDITIONAL COLUMN WILL BE SELECTED[/COLOR]
End If
Next iCtr
End With
End Sub
Any help would be greatly appreciated.
Many thanks
James