Loop?
some examples:
you can use the index number:
Worksheets(2).Activate
you can also use a variable:
dim i as long
for i = 1 to 3
Worksheets(i).Activate
next
or for each:
Dim ws As Worksheet
For Each ws In ThisWorkbook.Worksheets
ws.Activate
Next
--
Gary
"Varoujan" wrote in message
...
Thanks to all !
The one that works for me is : Application.CountA(Range("A2:A50"))
Funny, but when used directly in the worksheet, the "range" word is not
necessary.
It seems compulsory in VBA !
Another question please;
In the command : Worksheet("Name of sheet").activate
Can "Name of sheet" be a variable ? an array variable ? must be defined as
"string" of course ?
Varouj
"Tim" <tim j williams at gmail dot com a écrit dans le message de news:
...
Try
Application.CountA()
or
Application.Worksheetfunction.CountA()
Tim
"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
|