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

With the macro shown below, which works ok, the copied sheet
using the Copy before method, always go back to the start of the Worksheets,
which has
now got 16 sheets in the workbook and increases each month.
For the sake of convenience it would be nice for it to go back 1 worksheet
only.
ie before CurrentMasterHours worksheet.
Help please
Jim


<<<Dim Location
On Error Resume Next
Worksheets("CurrentMasterHours").Select
Location = InputBox("Enter Archive Name to be Stored, eg Sept '99",
"Time Sheets - Archival Transfer")
If Location = "" Then
Exit Sub
Else
Sheets("CurrentMasterHours").Copy befo=Sheets(1)
Sheets(1).Name = Location
End If
On Error GoTo 0
End Sub



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 104
Default Copy Sheet Problem

Jim,

Sheets("CurrentMasterHours").Copy befo=Sheets("CurrentMasterHours")
ActiveSheet.Name = Location

HTH
Henry


"Jim" wrote in message
. ..
With the macro shown below, which works ok, the copied sheet
using the Copy before method, always go back to the start of the

Worksheets,
which has
now got 16 sheets in the workbook and increases each month.
For the sake of convenience it would be nice for it to go back 1 worksheet
only.
ie before CurrentMasterHours worksheet.
Help please
Jim


<<<Dim Location
On Error Resume Next
Worksheets("CurrentMasterHours").Select
Location = InputBox("Enter Archive Name to be Stored, eg Sept

'99",
"Time Sheets - Archival Transfer")
If Location = "" Then
Exit Sub
Else
Sheets("CurrentMasterHours").Copy befo=Sheets(1)
Sheets(1).Name = Location
End If
On Error GoTo 0
End Sub





  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Copy Sheet Problem

Jim,

Change the line

Sheets("CurrentMasterHours").Copy befo=Sheets(1)

to

Sheets("CurrentMasterHours").Copy
befo=workSheets(("CurrentMasterHours")


not tested, but should work

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Jim" wrote in message
. ..
With the macro shown below, which works ok, the copied sheet
using the Copy before method, always go back to the start of the

Worksheets,
which has
now got 16 sheets in the workbook and increases each month.
For the sake of convenience it would be nice for it to go back 1 worksheet
only.
ie before CurrentMasterHours worksheet.
Help please
Jim


<<<Dim Location
On Error Resume Next
Worksheets("CurrentMasterHours").Select
Location = InputBox("Enter Archive Name to be Stored, eg Sept

'99",
"Time Sheets - Archival Transfer")
If Location = "" Then
Exit Sub
Else
Sheets("CurrentMasterHours").Copy befo=Sheets(1)
Sheets(1).Name = Location
End If
On Error GoTo 0
End Sub





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Copy Sheet Problem

Sheets("CurrentMasterHours").Copy befo=Sheets(sheets.count)

--
Regards,
Tom Ogilvy


Jim wrote in message
. ..
With the macro shown below, which works ok, the copied sheet
using the Copy before method, always go back to the start of the

Worksheets,
which has
now got 16 sheets in the workbook and increases each month.
For the sake of convenience it would be nice for it to go back 1 worksheet
only.
ie before CurrentMasterHours worksheet.
Help please
Jim


<<<Dim Location
On Error Resume Next
Worksheets("CurrentMasterHours").Select
Location = InputBox("Enter Archive Name to be Stored, eg Sept

'99",
"Time Sheets - Archival Transfer")
If Location = "" Then
Exit Sub
Else
Sheets("CurrentMasterHours").Copy befo=Sheets(1)
Sheets(1).Name = Location
End If
On Error GoTo 0
End Sub





  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default Copy Sheet Problem

Many thanks Henry, works just fine
Jim

"Henry" wrote in message
...
Jim,

Sheets("CurrentMasterHours").Copy befo=Sheets("CurrentMasterHours")
ActiveSheet.Name = Location

HTH
Henry


"Jim" wrote in message
. ..
With the macro shown below, which works ok, the copied sheet
using the Copy before method, always go back to the start of the

Worksheets,
which has
now got 16 sheets in the workbook and increases each month.
For the sake of convenience it would be nice for it to go back 1

worksheet
only.
ie before CurrentMasterHours worksheet.
Help please
Jim


<<<Dim Location
On Error Resume Next
Worksheets("CurrentMasterHours").Select
Location = InputBox("Enter Archive Name to be Stored, eg Sept

'99",
"Time Sheets - Archival Transfer")
If Location = "" Then
Exit Sub
Else
Sheets("CurrentMasterHours").Copy befo=Sheets(1)
Sheets(1).Name = Location
End If
On Error GoTo 0
End Sub









  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default Copy Sheet Problem

Hi Bob
Many thanks, had to change
Sheets(1).Name = Location
to
ActiveSheet.Name = Location
because it generated a second CurrentMasterHours Sheet(2)!!
Henrys code worked fine.
Many thanks for your help.
Jim

"Bob Phillips" wrote in message
...
Jim,

Change the line

Sheets("CurrentMasterHours").Copy befo=Sheets(1)

to

Sheets("CurrentMasterHours").Copy
befo=workSheets(("CurrentMasterHours")


not tested, but should work

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Jim" wrote in message
. ..
With the macro shown below, which works ok, the copied sheet
using the Copy before method, always go back to the start of the

Worksheets,
which has
now got 16 sheets in the workbook and increases each month.
For the sake of convenience it would be nice for it to go back 1

worksheet
only.
ie before CurrentMasterHours worksheet.
Help please
Jim


<<<Dim Location
On Error Resume Next
Worksheets("CurrentMasterHours").Select
Location = InputBox("Enter Archive Name to be Stored, eg Sept

'99",
"Time Sheets - Archival Transfer")
If Location = "" Then
Exit Sub
Else
Sheets("CurrentMasterHours").Copy befo=Sheets(1)
Sheets(1).Name = Location
End If
On Error GoTo 0
End Sub







  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default Copy Sheet Problem

Hi Tom
Sadly, it didn't work, it generated a second copy of CurrentMasterHours(2)
and also no archived sheet.
Henrys solution worked fine.
Many thanks
Jim
PS I do like one liners very much though!!


"Tom Ogilvy" wrote in message
...
Sheets("CurrentMasterHours").Copy befo=Sheets(sheets.count)

--
Regards,
Tom Ogilvy


Jim wrote in message
. ..
With the macro shown below, which works ok, the copied sheet
using the Copy before method, always go back to the start of the

Worksheets,
which has
now got 16 sheets in the workbook and increases each month.
For the sake of convenience it would be nice for it to go back 1

worksheet
only.
ie before CurrentMasterHours worksheet.
Help please
Jim


<<<Dim Location
On Error Resume Next
Worksheets("CurrentMasterHours").Select
Location = InputBox("Enter Archive Name to be Stored, eg Sept

'99",
"Time Sheets - Archival Transfer")
If Location = "" Then
Exit Sub
Else
Sheets("CurrentMasterHours").Copy befo=Sheets(1)
Sheets(1).Name = Location
End If
On Error GoTo 0
End Sub







  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Copy Sheet Problem

All code that copies the CurrentMasterHours sheet will initially produce
CurrentMasterHours(2) (or a numerical variant if there are other similarly
named sheets) until you rename it. So does Henry's solution. You weren't
aware of this????

Mine was obviously the worst solution because I took your description
literally and missed the "I.E." as to what you meant by one sheet back. Not
sure what you mean by no archived sheet - you we able to figure out how to
rename the sheet with Bob's code, but not mine (LOL). One copy command, One
copy of the sheet produced - same as Henry and Bob's solution and your
original code - only difference is the location.

--
Regards,
Tom Ogilvy




Jim wrote in message
...
Hi Tom
Sadly, it didn't work, it generated a second copy of CurrentMasterHours(2)
and also no archived sheet.
Henrys solution worked fine.
Many thanks
Jim
PS I do like one liners very much though!!


"Tom Ogilvy" wrote in message
...
Sheets("CurrentMasterHours").Copy befo=Sheets(sheets.count)

--
Regards,
Tom Ogilvy


Jim wrote in message
. ..
With the macro shown below, which works ok, the copied sheet
using the Copy before method, always go back to the start of the

Worksheets,
which has
now got 16 sheets in the workbook and increases each month.
For the sake of convenience it would be nice for it to go back 1

worksheet
only.
ie before CurrentMasterHours worksheet.
Help please
Jim


<<<Dim Location
On Error Resume Next
Worksheets("CurrentMasterHours").Select
Location = InputBox("Enter Archive Name to be Stored, eg Sept

'99",
"Time Sheets - Archival Transfer")
If Location = "" Then
Exit Sub
Else
Sheets("CurrentMasterHours").Copy befo=Sheets(1)
Sheets(1).Name = Location
End If
On Error GoTo 0
End Sub









  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default Copy Sheet Problem

Hi Tom
Yes, if you look at the original code, you can see how I renamed the Sheet,
Henrys solution worked fine, but yours fell over in the rename of worksheet
event I suspect.
Thanks for your continuing interest.
Have reproduced my original code for your perusal.
Perhaps there is a more efficient line or two of code to do what I want?
Thoughts always appreciated, as I am still learning !!!!!
Regards
Jim

<<<Dim Location
On Error Resume Next
Worksheets("CurrentMasterHours").Select
Location = InputBox("Enter Archive Name to be Stored, eg Sept '99",
"Time Sheets - Archival Transfer")
If Location = "" Then
Exit Sub
Else
Sheets("CurrentMasterHours").Copy befo=Sheets(1)
Sheets(1).Name = Location
End If
On Error GoTo 0
End Sub






"Tom Ogilvy" wrote in message
...
All code that copies the CurrentMasterHours sheet will initially produce
CurrentMasterHours(2) (or a numerical variant if there are other similarly
named sheets) until you rename it. So does Henry's solution. You weren't
aware of this????

Mine was obviously the worst solution because I took your description
literally and missed the "I.E." as to what you meant by one sheet back.

Not
sure what you mean by no archived sheet - you we able to figure out how to
rename the sheet with Bob's code, but not mine (LOL). One copy command,

One
copy of the sheet produced - same as Henry and Bob's solution and your
original code - only difference is the location.

--
Regards,
Tom Ogilvy




Jim wrote in message
...
Hi Tom
Sadly, it didn't work, it generated a second copy of

CurrentMasterHours(2)
and also no archived sheet.
Henrys solution worked fine.
Many thanks
Jim
PS I do like one liners very much though!!


"Tom Ogilvy" wrote in message
...
Sheets("CurrentMasterHours").Copy befo=Sheets(sheets.count)

--
Regards,
Tom Ogilvy


Jim wrote in message
. ..
With the macro shown below, which works ok, the copied sheet
using the Copy before method, always go back to the start of the
Worksheets,
which has
now got 16 sheets in the workbook and increases each month.
For the sake of convenience it would be nice for it to go back 1

worksheet
only.
ie before CurrentMasterHours worksheet.
Help please
Jim


<<<Dim Location
On Error Resume Next
Worksheets("CurrentMasterHours").Select
Location = InputBox("Enter Archive Name to be Stored, eg

Sept
'99",
"Time Sheets - Archival Transfer")
If Location = "" Then
Exit Sub
Else
Sheets("CurrentMasterHours").Copy befo=Sheets(1)
Sheets(1).Name = Location
End If
On Error GoTo 0
End Sub











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
copy rows from one Data sheet to another sheet based on cell conte John McKeon Excel Discussion (Misc queries) 2 May 15th 10 06:49 AM
Auto Copy/autofill Text from sheet to sheet if meets criteria Joyce Excel Discussion (Misc queries) 0 November 20th 08 11:05 PM
How can i copy data from a tabbed working sheet to a summary sheet StephenF Excel Discussion (Misc queries) 1 March 15th 07 03:40 PM
how to copy a cell with formula from sheet 1 (data is all vertical) into sheet 2 parag Excel Worksheet Functions 3 June 15th 06 10:29 PM
relative sheet references ala sheet(-1)!B11 so I can copy a sheet. RonMc5 Excel Discussion (Misc queries) 9 February 3rd 05 12:51 AM


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