LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
KR KR is offline
external usenet poster
 
Posts: 121
Default Easy Syntax question: referring to worksheet by VBA name

I've renamed my worksheets in the VBE properties window ("Apple", "Pear",
"Melon"); in the Excel user view, they still show up as "sheet1", sheet2",
and "sheet3".

Now in my VBA I need to refer to a range on a selected sheet. If I hardcode
it, I can use:
Apple.Range("B4:F17").Select

but I'm pulling in the appropriate sheet name as a text string, "Apple" or
"Pear" or "Melon".

How do I use this dynamically? I'm sure it is something close to:

Dim oWrkSht as Worksheet

Set oWrkSht = "Apple"

oWrkSht.Range("B4:F17").Select

but I get a type mismatch, because the sheet can't be set to a string...

I'm sure there is an easy way to do this...

Thanks,
Keith

--
The enclosed questions or comments are entirely mine and don't represent the
thoughts, views, or policy of my employer. Any errors or omissions are my
own.


 
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
Easy question - copying worksheet and keeping formulas vj1031 Excel Discussion (Misc queries) 2 October 29th 08 04:03 PM
new user with easy question? not easy for me speakeztruth New Users to Excel 5 June 3rd 05 09:40 PM
Easy VBA Syntax Question Hulk[_6_] Excel Programming 4 October 13th 04 07:23 PM
Easy VBA Syntax Question Hulk[_7_] Excel Programming 0 October 13th 04 06:41 PM
Syntax when referring to self Jack Schitt Excel Programming 3 September 2nd 04 02:04 AM


All times are GMT +1. The time now is 07:01 AM.

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"