Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 396
Default Get the name of worksheet behind active worksheet

Hi, i am trying to piece together some code to do the above. When i open
the file the active sheet name will always be "New gAMS" and the sheet
behind it will be a date "xx_xx_xx" and i need this sheet name as a
string variable to use further on..

Any help would be appreciated..

Les Stout

*** Sent via Developersdex http://www.developersdex.com ***
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,355
Default Get the name of worksheet behind active worksheet

Les,

Are you saying that you have two sheets in your workbook and that the first
worksheet is "New gAMS". You need the name of the second sheet in the
book? Is this correct?


"Les Stout" wrote:

Hi, i am trying to piece together some code to do the above. When i open
the file the active sheet name will always be "New gAMS" and the sheet
behind it will be a date "xx_xx_xx" and i need this sheet name as a
string variable to use further on..

Any help would be appreciated..

Les Stout

*** Sent via Developersdex http://www.developersdex.com ***

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,355
Default Get the name of worksheet behind active worksheet

Can you make any modifications in this workbook now? If so. you might want
to give the date sheet a code name that you can control. Let me know and we
can go further.

"Les Stout" wrote:

Hi, i am trying to piece together some code to do the above. When i open
the file the active sheet name will always be "New gAMS" and the sheet
behind it will be a date "xx_xx_xx" and i need this sheet name as a
string variable to use further on..

Any help would be appreciated..

Les Stout

*** Sent via Developersdex http://www.developersdex.com ***

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 396
Default Get the name of worksheet behind active worksheet

Hi Barb, it is a report that i generate weekly and name the sheet with
the day's date and then the difference of the last sheet to the new
sheet is put into the sheet New gAMS..

Les Stout

*** Sent via Developersdex http://www.developersdex.com ***
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,355
Default Get the name of worksheet behind active worksheet

Alt F11 to see the VB editor
Ctrl R to see the Project Explorer.
Select the sheet that is for the date.
F4 to see the properties for that sheet.

The name of the sheet should be displayed. It probably shows Sheet1, Sheet2
or something like that. Change it to something that makes sense for the
sheet. Let's say you call it DATE

to get the name that's on the tab for the sheet, you'll need DATE.Name

Try that and come back with more questions.

"Les Stout" wrote:

Hi Barb, it is a report that i generate weekly and name the sheet with
the day's date and then the difference of the last sheet to the new
sheet is put into the sheet New gAMS..

Les Stout

*** Sent via Developersdex http://www.developersdex.com ***



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,355
Default Get the name of worksheet behind active worksheet

Just discovered that DATE is not a legal name. Try something else.

"Les Stout" wrote:

Hi Barb, it is a report that i generate weekly and name the sheet with
the day's date and then the difference of the last sheet to the new
sheet is put into the sheet New gAMS..

Les Stout

*** Sent via Developersdex http://www.developersdex.com ***

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default Get the name of worksheet behind active worksheet

Hi Barb, i tried that, called it "LastSheet" but cant get it to work...
sorry not a programmer but a dabbler..


Barb Reinhardt wrote:
Just discovered that DATE is not a legal name. Try something else.

"Les Stout" wrote:

Hi Barb, it is a report that i generate weekly and name the sheet with
the day's date and then the difference of the last sheet to the new
sheet is put into the sheet New gAMS..

Les Stout

*** Sent via Developersdex http://www.developersdex.com ***


  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default Get the name of worksheet behind active worksheet

Hi Barb, i tried that, called it "LastSheet" but cant get it to work...
sorry not a programmer but a dabbler..


Barb Reinhardt wrote:
Just discovered that DATE is not a legal name. Try something else.

"Les Stout" wrote:

Hi Barb, it is a report that i generate weekly and name the sheet with
the day's date and then the difference of the last sheet to the new
sheet is put into the sheet New gAMS..

Les Stout

*** Sent via Developersdex http://www.developersdex.com ***


  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,355
Default Get the name of worksheet behind active worksheet

what do you have for code so far?

"Les" wrote:

Hi Barb, i tried that, called it "LastSheet" but cant get it to work...
sorry not a programmer but a dabbler..


Barb Reinhardt wrote:
Just discovered that DATE is not a legal name. Try something else.

"Les Stout" wrote:

Hi Barb, it is a report that i generate weekly and name the sheet with
the day's date and then the difference of the last sheet to the new
sheet is put into the sheet New gAMS..

Les Stout

*** Sent via Developersdex http://www.developersdex.com ***



  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 396
Default Get the name of worksheet behind active worksheet

Hi Barb, herewith code so far.

Sub TestNames()
Dim sh As Worksheet
Dim shName As String
Workbooks("gAMS_Report_Sep_06.xls").Worksheets(Las tSheet).Name = sh
shName = sh
MsgBox shName

End Sub


Les Stout

*** Sent via Developersdex http://www.developersdex.com ***


  #11   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,355
Default Get the name of worksheet behind active worksheet

Let's start this again. When you open the workbook, you want the new Gams
worksheet to be at the top. Change the code name for the "New gAMS" sheet
to New_GAMs.


On the project explorer page, you'll also see ThisWorkbook. Right click on
that and select View Code

Click on GENERAL and pull down to Workbook. Mine defaulted to Workbook_Open

Put this code in there

Private Sub Workbook_Open()
Sheets(New_GAMs.Name).Select
End Sub

You'll always get the New gAMs sheet selected when you open the workbook.



"Les Stout" wrote:

Hi, i am trying to piece together some code to do the above. When i open
the file the active sheet name will always be "New gAMS" and the sheet
behind it will be a date "xx_xx_xx" and i need this sheet name as a
string variable to use further on..

Any help would be appreciated..

Les Stout

*** Sent via Developersdex http://www.developersdex.com ***

  #12   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default Get the name of worksheet behind active worksheet

Hi barb, the worksheet "New gAMS" is always on top when the workbook
opens, i need to know the tab name of the sheet behind it. However i
think that i have managed to get it with:
"Application.Workbooks("gAMS_Report_Sep_06.xls").S heets(2).Name". as i
always put the new sheet in front so the last sheet would always be
sheet1 = "New gAMS", sheet2 = the sheet behind.....

Thanks so much for the input

Best regards,

Les

Barb Reinhardt wrote:
Let's start this again. When you open the workbook, you want the new Gams
worksheet to be at the top. Change the code name for the "New gAMS" sheet
to New_GAMs.


On the project explorer page, you'll also see ThisWorkbook. Right click on
that and select View Code

Click on GENERAL and pull down to Workbook. Mine defaulted to Workbook_Open

Put this code in there

Private Sub Workbook_Open()
Sheets(New_GAMs.Name).Select
End Sub

You'll always get the New gAMs sheet selected when you open the workbook.



"Les Stout" wrote:

Hi, i am trying to piece together some code to do the above. When i open
the file the active sheet name will always be "New gAMS" and the sheet
behind it will be a date "xx_xx_xx" and i need this sheet name as a
string variable to use further on..

Any help would be appreciated..

Les Stout

*** Sent via Developersdex http://www.developersdex.com ***


  #13   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 29
Default Get the name of worksheet behind active worksheet

G'day there Les,

Hi barb, the worksheet "New gAMS" is always on top when the workbook
opens, i need to know the tab name of the sheet behind it. However i
think that i have managed to get it with:
"Application.Workbooks("gAMS_Report_Sep_06.xls").S heets(2).Name". as i
always put the new sheet in front so the last sheet would always be
sheet1 = "New gAMS", sheet2 = the sheet behind.....


I came into this thread a little late, so you may well have
everything in hand, but I was able to get the sheet name this way:

Public Sub test()

Dim iX As Integer
Dim iY As Integer
Dim sNAME As String

iX = ThisWorkbook.ActiveSheet.Index
iY = iX + 1

sNAME = Sheets(iY).Name

End Sub

Perhaps you could derive something from that?

--
See ya,
Ken McLennan
Qld, Australia
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
Copying the active worksheet to another worksheet in the same work queenmaam Excel Worksheet Functions 5 March 25th 08 06:56 PM
Basic Question - How do I return the worksheet number of the active worksheet? Regnab Excel Programming 2 May 17th 06 03:02 AM
Altering code to reference the worksheet before the active worksheet KimberlyC Excel Programming 8 March 15th 05 10:26 PM
copy active worksheet plus another worksheet Qaspec Excel Programming 1 February 2nd 05 01:51 PM
macro to apply worksheet event to active worksheet Paul Simon[_2_] Excel Programming 3 August 7th 03 02:50 AM


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