Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default telling a macro to go back to where it came from

How can I modify this so that Excel will go back to the workbook it
came from? This macro goes from "company financials" over to my macro
sheet "Formatting Macros.xls". I want to use it for others like
"Division 1.xls" and "Division 2.xls", etc. so I need some way of
telling it to just go back to where it started. Please help.

Windows("FORMATTING MACROS.xls").Activate
Application.Run Range("ScOnWindow")
Range("N6").Select
Selection.Copy
Windows("COMPANY FINANCIALS.xls").Activate
Application.Run Range("ScOnWindow")
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,355
Default telling a macro to go back to where it came from

TRy adding this

Dim aWB as workbook

Set aWB = activeworkbook 'Put this at the beginning

When you want to return to the original workbook, put

awb.activate



" wrote:

How can I modify this so that Excel will go back to the workbook it
came from? This macro goes from "company financials" over to my macro
sheet "Formatting Macros.xls". I want to use it for others like
"Division 1.xls" and "Division 2.xls", etc. so I need some way of
telling it to just go back to where it started. Please help.

Windows("FORMATTING MACROS.xls").Activate
Application.Run Range("ScOnWindow")
Range("N6").Select
Selection.Copy
Windows("COMPANY FINANCIALS.xls").Activate
Application.Run Range("ScOnWindow")
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 45
Default telling a macro to go back to where it came from

Add this:

Dim MySheet as string
Dim MyCell as string

At the beginning of your macro, add:

MySheet=activesheet.name
MyCell=activecell.address

[your macro here...]

At the end of your macro add
Sheets(MySheet).activate
Range(MyCell).select




On Apr 6, 3:17 pm, wrote:
How can I modify this so that Excel will go back to the workbook it
came from? This macro goes from "company financials" over to my macro
sheet "Formatting Macros.xls". I want to use it for others like
"Division 1.xls" and "Division 2.xls", etc. so I need some way of
telling it to just go back to where it started. Please help.

Windows("FORMATTING MACROS.xls").Activate
Application.Run Range("ScOnWindow")
Range("N6").Select
Selection.Copy
Windows("COMPANY FINANCIALS.xls").Activate
Application.Run Range("ScOnWindow")
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False



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 back macro/roll back moh Excel Worksheet Functions 4 March 5th 07 02:19 PM
I'm adding 1.5 & 1 and VBA is telling me its 2 ?!?! dan Excel Programming 1 May 24th 06 05:25 PM
Telling a website what to do!! gunny1979[_3_] Excel Programming 1 April 1st 06 04:47 AM
Telling a procedure to end Phil1982 Excel Programming 1 March 16th 06 11:58 PM
telling Excel to go down relatively CC[_4_] Excel Programming 3 April 22nd 04 10:59 PM


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