Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Auto selection of previous sheet in workbook using a macro

Status
Not open for further replies.

Chris22

Technical User
Nov 27, 2002
7
GB
Hi guys,

Im new here and also new to VBA.

I have a workbook with various worksheets. I have a macro that copies the latest sheet (active) and places it after itself...if that makes sense. That works fine.

What I need to do now is write a macro that selects a range from the "previous" sheet and copies/pastes into into the latest sheet.

I cant find a command that selects the previous sheet....any clues ..??

Regards,

Chris22
 
Before you copy the sheet, make sure to remember it:

dim Sh as worksheet
set Sh=activesheet
activesheet.copy .... (make sheet called Newsheet)
sheets("newsheet").activate
Sh.range("A1:Z10").copy range("A2")

the final statement copies a range from your old sheet to the new one.

Rob
[flowerface]
 
Rob,

Maybe just me, but I could not get that to work...

Thanks anyway

Regards,

Chris
 
I'm sure I can help you if you tell me at what point it doesn't work. If you copied what I suggested verbatim, you'll need to complete the ... For example:

dim Sh as worksheet
set Sh=activesheet
activesheet.copy
activesheet.name="NewSheet"
Sh.range("A1:Z10").copy range("A2")

Does that help?
Rob
[flowerface]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top