ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   columns in refedit to a combobox (https://www.excelbanter.com/excel-programming/398415-columns-refedit-combobox.html)

LuisE

columns in refedit to a combobox
 
How can I populate a ComboBox with the columns of a range selected in a
RedEdit?

Thanks in advance

joel

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



All times are GMT +1. The time now is 01:34 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com