Range query

S

Steve

HI all,
Am using the code below to operate a combobox, but would like it to
read the information from the top line of the worksheet, currently is
reading down

Any help with this would be appreciated,


Private Sub userform_Activate()
Dim iLastRow As Long
Dim i As Long
With Worksheets("Work Data")
iLastRow = .Cells(.Rows.Count, "1").End(xlUp).Row
Me.ComboBox1.Clear
For i = E To iLastRow
Me.ComboBox1.AddItem .Cells(i, "1").Value
Next i
End With
End Sub


HYCH

Steve
 
D

Dave Peterson

I'm not sure I understand, but maybe...

Change this:
For i = E To iLastRow
to
For i = iLastRow to E step -1

(I'm not sure what E is, either.)
 
S

Steve

I'm not sure I understand, but maybe...

Change this:
For i = E To iLastRow
to
For i = iLastRow to E step -1

(I'm not sure what E is, either.)








--

Dave Peterson- Hide quoted text -

- Show quoted text -

sorry dave i was trying to adjust the code i had to read across
columns rather than reading down rows.

the original code had that as: For i = 1 To iLastRow

i expected that the no indicated row numbers where as columns are
usually represnted by Letters,

obviously not the right method lol.

All i am looking for is my combobox to read accross the columns rather
than down the rows
 
D

Dave Peterson

dim lastCol as long
dim i as long
With worksheets("work data")
'I used row 1
lastcol = .cells(1, .columns.count).end(xltoleft).column
Me.ComboBox1.Clear
for i = 1 to lastcol
Me.ComboBox1.AddItem .Cells(1, icol).Value
....
 
S

Steve

dim lastCol as long
dim i as long
With worksheets("work data")
'I used row 1
lastcol = .cells(1, .columns.count).end(xltoleft).column
Me.ComboBox1.Clear
for i = 1 to lastcol
Me.ComboBox1.AddItem .Cells(1, icol).Value
....











--

Dave Peterson- Hide quoted text -

- Show quoted text -

Dave,

Just knew you would have the answer as soon as i made myself clear
lol, again thanks :)


Steve
 
D

Dave Peterson

I think a lot of people were confused with your question <vbg>. Your original
post had gone a couple of hours without a response. That usually means that
there's confusion on at least one end <bg>.

Steve wrote:
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top