Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 36
Default Return to previous worksheet after code pastes in another worksheet?

Hi Guys,

Im teaching myself vba [or trying to!] so my code attempts may reek of
amateur, but hell, we all started somewhere.


I have 35 very similar worksheets that grab financial data from a web
query. I only use one sheet at a time though. The active sheet then has
to format a load of data and paste it into a mastersheet.

What I need to do but can't grasp it is when I am in the active sheet and
do a cut of the relevant data, then tell my code to select the 'Data
Collection' worksheet and pastes it, I need to go back to the previous
sheet to clear some leftover data ready for the next time this particular
collection sheet is used.

I tried to set the activesheet name as a variable to refer back to it later
but it simply stays in the 'Data Collection' worksheet instead of going
back, or I generate a vba error.

Any help would be appreciated.

Ron
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22,906
Default Return to previous worksheet after code pastes in another worksheet?

Ron

Do not select the Data Collection sheet.

ActiveSheet.Range("A1:J10").Cut _
Destination:=Worksheets("Data Collection").Range("A1")

Will leave you on the Activesheet.

To cut and paste to next available blank row on Data Collection sheet

ActiveSheet.Range("A1:J10").Cut _
Destination:=Worksheets("Data Collection").Cells(Rows.Count, 1) _
.End(xlUp).Offset(1, 0)

Gord Dibben Excel MVP


On 04 Sep 2004 16:50:59 GMT, Ron wrote:

Hi Guys,

Im teaching myself vba [or trying to!] so my code attempts may reek of
amateur, but hell, we all started somewhere.


I have 35 very similar worksheets that grab financial data from a web
query. I only use one sheet at a time though. The active sheet then has
to format a load of data and paste it into a mastersheet.

What I need to do but can't grasp it is when I am in the active sheet and
do a cut of the relevant data, then tell my code to select the 'Data
Collection' worksheet and pastes it, I need to go back to the previous
sheet to clear some leftover data ready for the next time this particular
collection sheet is used.

I tried to set the activesheet name as a variable to refer back to it later
but it simply stays in the 'Data Collection' worksheet instead of going
back, or I generate a vba error.

Any help would be appreciated.

Ron


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 36
Default Return to previous worksheet after code pastes in another worksheet?

Don and Gord,

Thanks guys for answering so quick.

I was trying to copy from the source sheet and go to the destination sheet
and then back to the source sheet.

The examples you have both gave will help me no end in the future, thankyou
both.

Ron
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,337
Default Return to previous worksheet after code pastes in another worksheet?

As we said, you do not need to go back and forth. Just copy or cut to the
destination sheet.

--
Don Guillett
SalesAid Software

"Ron" wrote in message
10.200...
Don and Gord,

Thanks guys for answering so quick.

I was trying to copy from the source sheet and go to the destination sheet
and then back to the source sheet.

The examples you have both gave will help me no end in the future,

thankyou
both.

Ron



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
reference cell from previous worksheet without "naming" worksheet Kristin Excel Worksheet Functions 3 August 20th 07 08:30 PM
Returning To Previous Worksheet - Help with sebastienm's code AcesUp Excel Discussion (Misc queries) 0 June 3rd 06 12:47 PM
I need to return the name of a worksheet in another worksheet cell? Rick Excel Worksheet Functions 2 June 23rd 05 01:47 AM
How do I return to a previous worksheet in Excel? chiell Excel Discussion (Misc queries) 2 May 5th 05 02:21 AM
Macro to return to previous worksheet gurs Excel Programming 6 October 17th 03 05:09 PM


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