ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Selecting previous worksheet (https://www.excelbanter.com/excel-programming/298809-selecting-previous-worksheet.html)

Carolyne[_2_]

Selecting previous worksheet
 
I'm trying to create a macro to add a new worksheet and select the
previous worksheet to copy it. I can only select by specific name i
just want whichever sheet is previous. Can anyone help.
This is what i have so far

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

The line below is where the problem is.

Sheets("12.05.04").Select
Cells.Select
Selection.Copy

SunTzuComm

Selecting previous worksheet
 
Carolyne,

I think "ActiveSheet.Previous.Select" should work. This simulates pressing
Ctrl+PageUp.

Regards,
Wes

SunTzuComm

Selecting previous worksheet
 
Carolyne,

On second thought, "ActiveSheet.Next.Select" is probably the one to use, since
Excel adds a new worksheet in front of the currently active one.

Regards,
Wes


All times are GMT +1. The time now is 10:06 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com