Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Sheet Position

I know that code can be written to reference sheets
according to their position in the Workbook, e.g.:

Sheets("abc").Copy Befo=Sheets(6)

The sheet that is in position 6 is called "End" but it
moves position as you copy more sheets into the file! So,
I need some code to be able to locate the numerical
position of the "End" sheet and put the variable back into
the 'copy' code above.

Any ideas anyone?!

Thanks,
James
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,337
Default Sheet Position

Try
sheets("End")

"James Weaver" wrote in message
...
I know that code can be written to reference sheets
according to their position in the Workbook, e.g.:

Sheets("abc").Copy Befo=Sheets(6)

The sheet that is in position 6 is called "End" but it
moves position as you copy more sheets into the file! So,
I need some code to be able to locate the numerical
position of the "End" sheet and put the variable back into
the 'copy' code above.

Any ideas anyone?!

Thanks,
James



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 96
Default Sheet Position

Is this what you're trying to do?

Sheets("abc").Copy Befo=Sheets(Sheets.Count)

HTH
Paul
--------------------------------------------------------------------------------------------------------------
Be advised to back up your WorkBook before attempting to make changes.
--------------------------------------------------------------------------------------------------------------

I know that code can be written to reference sheets
according to their position in the Workbook, e.g.:

Sheets("abc").Copy Befo=Sheets(6)

The sheet that is in position 6 is called "End" but it
moves position as you copy more sheets into the file! So,
I need some code to be able to locate the numerical
position of the "End" sheet and put the variable back into
the 'copy' code above.

Any ideas anyone?!

Thanks,
James


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 176
Default Sheet Position

James,


Also, do you know how to check whether a sheet already
exists?


Try to read a sheet property, and trap the error. Example:

Sub TryNow()
Dim myName As String
Dim myTest As String
On Error GoTo NoSheet
myTest = "TestSheet"

myName = Worksheets(myTest).Name
MsgBox "Sheet " & myTest & " exists"
Exit Sub

NoSheet:
MsgBox "Sheet " & myTest & " does not exist."
End Sub


--
HTH,
Bernie




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 860
Default Sheet Position

Hi James,

Here's a function to determine if a sheet exists:

Public Function gbSheetExists(rsShtName As String, _
Optional rwbWorkbook As Workbook) As Boolean
On Error Resume Next
If rwbWorkbook Is Nothing Then
gbSheetExists = Len(Sheets(rsShtName).Name)
Else
gbSheetExists = Len(rwbWorkbook.Sheets(rsShtName).Name)
End If
End Function

--
Regards,

Jake Marx
www.longhead.com

James Weaver wrote:
Great - thanks.

Also, do you know how to check whether a sheet already
exists?

James
-----Original Message-----
Try
sheets("End")

"James Weaver" wrote in message
...
I know that code can be written to reference sheets
according to their position in the Workbook, e.g.:

Sheets("abc").Copy Befo=Sheets(6)

The sheet that is in position 6 is called "End" but it
moves position as you copy more sheets into the file! So,
I need some code to be able to locate the numerical
position of the "End" sheet and put the variable back into
the 'copy' code above.

Any ideas anyone?!

Thanks,
James



.

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
change sheet position right to left Aicha Excel Discussion (Misc queries) 4 July 22nd 07 10:04 AM
macro sheet position jay d Excel Worksheet Functions 2 June 5th 06 02:51 PM
keep active sheet view and cursor position killa47 Excel Worksheet Functions 0 November 8th 05 09:20 AM
Moving rows to sequential position on another sheet Jenno Excel Discussion (Misc queries) 5 August 15th 05 09:48 AM
how can i trace position in marks sheet adeel afzal via OfficeKB.com Excel Worksheet Functions 3 July 31st 05 08:39 PM


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

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"