columns in refedit to a combobox
with userform1
.combobox1.text = .refedit1.text
end with
lets say the string return is
refeditrange = "sheet1!$A5:$B10"
You can extract the columns using string references or cell references
set cellrange = range(refeditrange)
firstcol = cellrange.column
lastcolumn = firstcol + cellrange.columns - 1
you can do the same using string manipulations
Sub test()
refeditrange = "sheet1!$A5:$B10"
'get everything after first $
Firstcol = Mid(refeditrange, _
InStr(refeditrange, "$") + 1)
Lastcol = Firstcol
'check if column is one letter of two letters
If IsNumeric(Mid(Firstcol, 2, 1)) Then
'Column is A - Z
Firstcol = Left(Firstcol, 1)
Else
'Column is AA - IV
Firstcol = Left(Firstcol, 2)
End If
'get characters after 2nd $
Lastcol = Mid(Lastcol, _
InStr(Lastcol, "$") + 1)
If IsNumeric(Mid(Lastcol, 2, 1)) Then
'Column is A - Z
Lastcol = Left(Lastcol, 1)
Else
'Column is AA - IV
Lastcol = Left(Lastcol, 2)
End If
End Sub
"LuisE" wrote:
How can I populate a ComboBox with the columns of a range selected in a
RedEdit?
Thanks in advance
|