Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 101
Default Get WorkSheet Name without a reason

Hello Masters,

I have a macro which will get the list of worksheet names. It works
fine untill I add some more worksheets and run it again.

The craziest thing is that if I go to the code and simply add a space
of delete a space, or just cut and paste the code, it works fine.

Any idea what could be wrong??

Thanks in advance for any help

-DC

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,501
Default Get WorkSheet Name without a reason

It could only be a guess without seeing the code but here's some that does
wotk that you could maybe adapt:-

Sub getnames()
x = 1
Dim ws As Worksheet
For Each ws In ThisWorkbook.Worksheets
Sheets("Sheet1").Cells(x, 1).Value = ws.Name
x = x + 1
Next ws
End Sub

Mike

"Dileep Chandran" wrote:

Hello Masters,

I have a macro which will get the list of worksheet names. It works
fine untill I add some more worksheets and run it again.

The craziest thing is that if I go to the code and simply add a space
of delete a space, or just cut and paste the code, it works fine.

Any idea what could be wrong??

Thanks in advance for any help

-DC


  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 101
Default Get WorkSheet Name without a reason

Hi Mike,

Thanks for your reply. I have the same code. But it still fails to
work without opening the code and refresh.

Heres my code:

Sub WsNames()

Dim i As Long
Dim Sh As Worksheet
i = 6


For Each Sh In ActiveWorkbook.Sheets

Range("B" & i) = Sh.Name
Range("A" & i) = Sh.CodeName
i = i + 1

Next

End Sub

Any idea to rectify?

Thanks

DC

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Column Widths Changing - For No Reason??? Paige Excel Discussion (Misc queries) 1 April 26th 07 12:34 AM
No reason for Large excel file-don't know why onewildchild Excel Discussion (Misc queries) 4 January 30th 07 04:36 PM
Formulas in are turning into values for no reason Steve Excel Worksheet Functions 1 February 4th 06 06:13 PM
Excel slows down for no(?) reason... thekovinc Excel Discussion (Misc queries) 0 December 6th 05 06:01 PM
Any reason for no allowance of avatars?? malik641 Excel Discussion (Misc queries) 4 July 21st 05 03:17 PM


All times are GMT +1. The time now is 11:38 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"