Help with Selection Property
Hi Shilps,
I don't know why it gives an error, but it is not good as it returns all of
the rows, that is 65536. You don't want this. What you want is
c1 = Cells(Rows.Count, "AR").End(xlUp).Row
try that and see if you still a combo error.
--
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 Bob!
As U said that I am trying to count the rows, I chaged the code to
following :
Dim c As Integer
Worksheets("ABC").Activate
ActiveSheet.Range("AR:AR").Select
c1 = Selection.Rows.Count
For c = 2 To c1
ComboBox15.AddItem CStr(Sheet1.Range("AR" + CStr(c)).Value)
Next c
But now it is giving error on line
For c = 2 To c1
But it is not giving error when I change the code to
Dim c As Integer
Worksheets("ABC").Activate
ActiveSheet.Range("AR:AR").Select
c1 = MsgBox(Selection.Rows.Count, , no)
For c = 2 To c1
ComboBox15.AddItem CStr(Sheet1.Range("AR" + CStr(c)).Value)
Next c
How does adding a msgbox statement change it?
Also if I change the code to, it gives error on "ComboBox15.AddItem
CStr(Sheet1.Range("AR" + CStr(c)).Value)"
Dim c As Long
Worksheets("ABC").Activate
ActiveSheet.Range("AR:AR").Select
c1 = Selection.Rows.Count
For c = 2 To c1
ComboBox15.AddItem CStr(Sheet1.Range("AR" + CStr(c)).Value)
Next c
TIH
Shilps
|