VBA Question

hemantmohan.1

New Member
Joined
Oct 26, 2010
Messages
30
Can u help me with these codes. As soon as i run this macro it gives an error and stops at the line in bold. Help will be greatly appreciated.

Public Sub CommandButton1_Click()

Dim d, m, y, od


Windows("Performance Sheet.xls").Activate
Sheets("Performance Sheet").Select

d = Range("A42").Value
od = Range("A46").Value
m = Range("A41").Value
y = Range("A43").Value

Application.ScreenUpdating = True
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
Re: hi All.

Shouldn't that be Workbooks("Performance Sheet.xls").Activate? By the way, you don't need to activate or select the file or sheet...

Code:
With Workbooks("Performance Sheet.xls").Sheets("Performance Sheet")

d = .Range("A42").Value
od = .Range("A46").Value
m = .Range("A41").Value
y = .Range("A43").Value

End With
 
Upvote 0
Re: hi All.

Hey mack,

Appreciate the solution. I was trying to run this macro at home, however the path that ia given in the following macro is from my office's sharedrive.

I know that it will not work here but can you tell me a way or a macro that i can use in order to collate data from a file by just mentioning the date as it will change on a daily basis.

What i mean to say is i will just enter the date and run the macro and it should copy the data from that file and paste it in the file from where i am running the macro ?
 
Upvote 0
Re: hi All.

Hey mack,

Appreciate the solution. I was trying to run this macro at home, however the path that ia given in the following macro is from my office's sharedrive.

I know that it will not work here but can you tell me a way or a macro that i can use in order to collate data from a file by just mentioning the date as it will change on a daily basis.

What i mean to say is i will just enter the date and run the macro and it should copy the data from that file and paste it in the file from where i am running the macro ?

Fairly simple to do but you need to provide specifics - file path, file name, ranges to be copied and where you want them copied to.
 
Upvote 0

Forum statistics

Threads
1,224,586
Messages
6,179,728
Members
452,939
Latest member
WCrawford

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