View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_6_] Bob Phillips[_6_] is offline
external usenet poster
 
Posts: 11,272
Default Help with Selection Property

Hi Ships,

Even if you got the syntax correct, it would not work as you are counting
the columns in a range. As the range is just one column, this would always
be 1. You need to count the rows, like so

Worksheets("Sheet1").Activate
For i = 1 To ActiveSheet.Cells(Rows.Count, "AR").End(xlUp).Row
ComboBox15.AddItem CStr(Sheet1.Range("AR" + CStr(i)).Value)
Next

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Shilps" wrote in message
...
Hi,
I have the following code
Dim count1 As Integer
Worksheets("ABC").Activate
ActiveSheet.Range("AR:AR").Select
count1 = Selection.Column.count
For i = 1 To count1
ComboBox15.AddItem CStr(Sheet1.Range("AR" + CStr(i)).Value)
Next

I want to know the last row number in column AR that contains the data

(Column AR has blank cells too ) and run the loop equal number of times.
But every time I run this code, it gives an error on line "count1 =

Selection.Column.count"
Plz help
Thnks