Excel 2003 Macro HELP NEEDED!!

drmmer07

New Member
Joined
Mar 22, 2010
Messages
8
Hello fellow excel guru's,

i have just managed to create a macro where once i select the 'button' where i have set the macro up to, there are two data sheets pasted into my workbook from another.

The issue i am facing is that the macro works if the other workbook is open, but as soon as i close the other workbook from where i am getting the data, i get the debugging error.

Can you please tell me why it works when the workbook is open but as soon as its closed the macro wont work?

Here is my macro below

Code:
Sub saledata()
'
' saledata Macro
' Macro recorded 20/04/2010 by david.pietersz
'
'
Sheets("Total Sales by Rep").Select
Range("D27").Select
Windows("P:\Shared\CONSUMER DIVISION SALE SCHEDULE\2010 Trackers\Reporting Summary\Sales Schedule Summary - Rep II").Activate
Cells.Select
Application.CutCopyMode = False
Selection.Copy
Windows("Home & Garden Sales Schedule - April 2010.xls").Activate
Range("A1").Select
ActiveSheet.Paste
Windows("Sales Schedule Summary - Rep II.xls").Activate
Sheets("Sales Stats").Select
Cells.Select
Application.CutCopyMode = False
Selection.Copy
Windows("Home & Garden Sales Schedule - April 2010.xls").Activate
Sheets("Sales Stats").Select
ActiveWindow.SmallScroll Down:=-9
Range("A1").Select
ActiveSheet.Paste
Range("C22").Select
Sheets("Sheet1").Select
ActiveWindow.SmallScroll Down:=-9
End Sub
 
Last edited by a moderator:

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
Welcome to the Board!

Can you please tell me why it works when the workbook is open but as soon as its closed the macro wont work?

Because it's closed and your code is referencing an open workbook. There are methods to pull data from closed workbooks, but in your case, I'd just record a macro opening the source wb and add that to the beginning of your code.

HTH,
 
Upvote 0

Forum statistics

Threads
1,215,507
Messages
6,125,212
Members
449,214
Latest member
mr_ordinaryboy

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top