View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Frank Kabel Frank Kabel is offline
external usenet poster
 
Posts: 3,885
Default Help with Selection Property

Hi
try something like the following:
Sub count_rows()
Dim RowNdx As Long
Dim LastRow As Long

LastRow = worksheets("ABC").Cells(Rows.Count, "AR").End(xlUp).row
For RowNdx = LastRow To 1 Step -1
If Cells(RowNdx, "AR").Value < "" Then
ComboBox15.AddItem CStr(Cells(RowNdx, "AR").Value)
End If
Next RowNdx
End Sub

--
Regards
Frank Kabel
Frankfurt, Germany


Shilps wrote:
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