LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default How do you capture the name of the current worksheet in VBA?

Chip,

I found that I also had to include the workbook object to get the desired
results:

Set wsht = wbk.ActiveSheet

otherwise it only worked intermittently.

Please see my reply to Krzysztof Naworyta in another thread in this
discussion for a bit more detail.

Thanks

Paul



"Chip Pearson" wrote in message
...
Set wsht = wbk.Worksheets(strActiveWorksheet)


You can simplify this to

Set wsht = ActiveSheet

Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2009
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)

On Fri, 25 Sep 2009 00:21:15 -0700, "Paul" wrote:

Ok, I finally got it to work.

I first tried

Set wsht = wbk.Worksheets(ActiveSheet.Name)

and that didn't work.

So then I assigned ActiveSheet.Name to a string variable

strActiveWorksheet = ActiveSheet.Name

and then usd the variable in the expression

Set wsht = wbk.Worksheets(strActiveWorksheet)

and it worked.

Thanks for providing me with the solution, Kevin.

Paul



 
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
Capture Worksheet Change Value Risky Dave Excel Programming 1 January 6th 09 06:43 PM
In a range of months can I capture the most current month entry? Karlene Excel Discussion (Misc queries) 4 August 15th 07 05:55 PM
Capture current WS Name? Dave Birley Excel Programming 5 May 8th 07 05:09 PM
Capture a worksheet in VBA Madiya Excel Programming 6 August 11th 06 03:40 PM
Capture Current Selection in a Combo Box Randy[_10_] Excel Programming 3 August 6th 04 09:43 PM


All times are GMT +1. The time now is 05:46 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"