Even a little shorter.
Public Sub SheetList()
For i = 1 To Sheets.Count
Cells(i, 1).Value = Sheets(i).Name
Next i
End Sub
On Jul 3, 3:53 am, Swapnil Palande wrote:
> Hi,
>
> Following is the correct code:
>
> Public Sub SheetList()
>
> Range("A1").Select
> For i = 1 To ActiveWorkb
Hi,
Following is the correct code:
Public Sub SheetList()
Range("A1").Select
For i = 1 To ActiveWorkbook.Sheets.Count
Cells(i, 1) = ActiveWorkbook.Sheets(i).Name
Next
End Sub
There is syntax error in your code in for loop
And "ActiveWorkbook.Sheets.Count" this line will return
i=1
For each s in Sheets
Sheets("YourSheet").Cells(i, 1) = s.Name
i = i + 1
Next s
Change "YourSheet" to the sheet name you on which want to record your sheet
names.
Regards - Dave.
> Date: Sat, 3 Jul 2010 02:05:42 -0700
> Subject: Re: $$Excel-Macro
i = ActiveWorkbook.Sheets.Count
Does ActiveWorkbook.Sheets.Count return an integer or a pointer to an
object in which case i can't be of both type. Then how "for i ..."
should be ?
Thx
Pascal
On Jul 3, 4:20 am, Dave Bonallack wrote:
> Hi,
> I don't think you can say "For i = 1 to i" since i is
Hi,
I don't think you can say "For i = 1 to i" since i is undefined.
Regards - Dave
> Date: Fri, 2 Jul 2010 11:52:06 -0700
> Subject: $$Excel-Macros$$ First sips of Vba for Excel : Worksheet listing
> From: bpascal...@gmail.com
> To: excel-macros@googlegroups.com
>
> Hi,
>
> Could you please te