LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #13   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 50
Default Why does this code not work?

Got it. thanks much again.

"Dave Peterson" wrote:

I was just commenting on ghdiez's first suggestion.

I didn't mean to suggest that his second suggestion would do what you wanted. I
would loop through the sheets using the code that I previously posted.

rk0909 wrote:

Dave.
somehow this does not work. "Sheet" & n does not work at all.

If I use Sheets(n). It refers to sheet tab name instead of code name.

Any suggestions will be appreciated.

RK
"Dave Peterson" wrote:

Just a note about your first suggestion:

1. wks = "sheet" & Trim(Str(n))

The Str function actually introduces that space character.
wks = "Sheet" & n
would would nicely--it wouldn't include any spaces.



wrote:

On 4 sep, 10:06, rk0909 wrote:
All,

I am trying to use the code name of sheets instead of the tab name, but it
wouldn't work for me. Any help will be appreciated.

Thanks much,

RK

Sub test()
Dim n As Integer

n = 1
wks = "sheet" & n

wks.Select
End Sub

Hi Rk:

You need to do some changes:

1. wks = "sheet" & Trim(Str(n))
This, becuase the n variable is numeric (integer) and the string
representation has a space at left. You should remove the space.

2. Worksheets(wks).Select
The reason is that wks is a string variable, not an object. You pass
the sheet name (the value of wks variable) to the Worksheets
collection.

--

Dave Peterson


--

Dave Peterson

 
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
code does not work anymore Wanna Learn Excel Discussion (Misc queries) 2 July 24th 08 03:51 PM
Event code won't work marker68 Excel Discussion (Misc queries) 2 April 2nd 08 01:13 AM
Why this code is not work? Error code when select worksheet Excel Worksheet Functions 4 December 4th 07 12:51 AM
Number Format Code won't work tbmarlie Excel Discussion (Misc queries) 2 October 15th 07 06:46 PM
code is not to work on sheet1 Allan R Jeffery New Users to Excel 3 August 22nd 06 02:22 PM


All times are GMT +1. The time now is 12:31 PM.

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

About Us

"It's about Microsoft Excel"