Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
XP XP is offline
external usenet poster
 
Posts: 389
Default VBA to extract sheet name

I am using Office 2003 on Windows XP.

I have a string that looks like: ='Sheet Name'!R22C7

This string is in a variable, so: sSheet = "='Sheet Name'!R22C7"

The length of the sheet name and the cell address changes each time.

I need, in VBA code, to strip out the SHEET NAME only.
Is it possible to do this in a SINGLE LINE of code?

Could someone please post example code that can do this?
Thanks much in advance

Thanks much in advance.
  #2   Report Post  
Posted to microsoft.public.excel.programming
ben ben is offline
external usenet poster
 
Posts: 232
Default VBA to extract sheet name

MyVariable = ActiveSheet.Name


or
MyVariable = Worksheets(1).Name

--
When you lose your mind, you free your life.


"XP" wrote:

I am using Office 2003 on Windows XP.

I have a string that looks like: ='Sheet Name'!R22C7

This string is in a variable, so: sSheet = "='Sheet Name'!R22C7"

The length of the sheet name and the cell address changes each time.

I need, in VBA code, to strip out the SHEET NAME only.
Is it possible to do this in a SINGLE LINE of code?

Could someone please post example code that can do this?
Thanks much in advance

Thanks much in advance.

  #3   Report Post  
Posted to microsoft.public.excel.programming
ben ben is offline
external usenet poster
 
Posts: 232
Default VBA to extract sheet name


MyVariable = "='Sheet Name'!R22C7"

MySheetName = Mid(MyVariable, InStr(1, MyVariable, "'") + 1,
InStrRev(MyVariable, "'") - InStr(1, MyVariable, "'") - 1)

MsgBox MySheetName




--
When you lose your mind, you free your life.


"XP" wrote:

I am using Office 2003 on Windows XP.

I have a string that looks like: ='Sheet Name'!R22C7

This string is in a variable, so: sSheet = "='Sheet Name'!R22C7"

The length of the sheet name and the cell address changes each time.

I need, in VBA code, to strip out the SHEET NAME only.
Is it possible to do this in a SINGLE LINE of code?

Could someone please post example code that can do this?
Thanks much in advance

Thanks much in advance.

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
Extract from one sheet to another Bcosta Excel Discussion (Misc queries) 5 July 7th 09 09:51 PM
How to extract a sheet from another? deedee Excel Discussion (Misc queries) 0 March 18th 09 10:26 PM
how to extract a sheet from another? deedee Excel Discussion (Misc queries) 2 March 18th 09 03:12 AM
Help me, compare 2 sheet and extract the match data into the new sheet. sweetnet Excel Discussion (Misc queries) 1 February 22nd 06 07:49 PM
Best way to extract data on one sheet & populate it on another sheet?????? WebWizard97 Excel Programming 1 September 25th 03 08:50 PM


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

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"