LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 48
Default Selecting previous worksheet

The difference between other suggestions and mine is...

1. This code is making sure that the sheet is added before the first
If we just add a sheet, it will be added before the current active
sheet
2. I am assuming that there can be another sheet with name Sheet 1
existing in which case, wrong sheet will be selected for processing.

Mine code may or may not be exactly suitable, so just clarified,
not to undermine the other replies.

Also, I strongly suggest putting an error handling for checking
existance of the sheet before adding it.

HTH

yogendra joshi wrote:

Try this...

The logic is...

1. Create the new sheet before the first sheet in the workbook
2. Now copy the data from second sheet (previousely first sheet)
3. Paste

Hope this helps...

Sub add_new()
d$ = Format(Now, "dd.mm.yy")
Set sht = Sheets.Add(Sheets(1))
sht.Name = d$
Sheets(2).Cells.Copy
'Cells.Copy
sht.Paste
Application.CutCopyMode = False
End Sub



Carolyne wrote:

I'm trying to create a macro that creates a new worksheet named todays
date and copys the whole of the previous sheet into it. I can only
seem to select the specific sheet name does anyone know how to select
the previous sheet.
I have this so far

d$ = Format(Now, "dd.mm.yy")
Sheets.Add
Sheets("sheet1").Select
Sheets("Sheet1").Name = d$

The line below is where i want to select the previous sheet.

Sheets("12.05.04").Select
Cells.Select




 
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
Inserting a new worksheet that is linked to a previous one Joanne Excel Worksheet Functions 0 December 8th 08 04:04 PM
Selecting a cell for fill-in by previous cells Carrie Excel Discussion (Misc queries) 2 July 8th 08 04:44 PM
Moving to Previous Worksheet Zootie Excel Worksheet Functions 1 October 4th 06 03:28 PM
Go back to previous worksheet BarryL New Users to Excel 2 May 5th 05 01:38 AM
reference to previous worksheet Daniel Lidström Excel Programming 2 December 16th 03 07:34 PM


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