Thread: Loop?
View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Don Guillett Don Guillett is offline
external usenet poster
 
Posts: 10,124
Default Loop?

try this to see which you REALLY want to use. Counta only counts if
something there.

Sub usecounta()
'For i = 1 To CountA("A2:A50")
'................do this , do that
' Next i
MsgBox Application.CountA(Range("a2:a50"))
MsgBox Range("a2:a50").Rows.Count

End Sub

--
Don Guillett
SalesAid Software

"Varoujan" wrote in message
...
Hi ,

I use excel but I'm new to programming, please excuse me if this is
trivial.
I have information on one sheet : let's call it Mainsheet and I want to
copy that info on several other shhets in the following manner.
The information on Main is like a database with the rows being the
records.
In the first cell of the row is one " name of the company".
I want to copy the information of that record on a sheet named the same
name as the company name and the info transposed in a column "B". the top
record labels being in column A of the company sheet. (I hope this makes
sense).
When I record a macro, everything goes well of course but Ias soon as I
try to make a loop to go through every record, I have errors.
Can someone please give me an idea of how this should be done ?
I already have created the company sheets, so no need to include the
creation of new sheets.

One additional question :
It seems that the "counta" function does not behave the same way when in
vba !
I get an error message whichever way I use it ?

Can I write :
For i= 1 to counta("A2:A50")
................do this , do that
next i

TIA