No way!

Joined
Mar 18, 2011
Messages
45
Guys,

I don't understand why it is not working.

Workbooks("C:\job.xls").Activate
Sheets("Report").Select
Range("A1:H1").Select
Selection.Copy
Workbooks.Open ("C:\FX.xls")
Sheets.Add.Name = "Exchange"
Range("A1").Select
Selection.Paste
Columns("A:A").ColumnWidth = 16
Columns("B:B").ColumnWidth = 23
Columns("C:C").ColumnWidth = 23
Columns("D:D").ColumnWidth = 23
Columns("E:E").ColumnWidth = 15
Columns("F:F").ColumnWidth = 15
Columns("G:G").ColumnWidth = 24
Columns("H:H").NumberFormat = "m/d/yyyy"

The code above doesn't work. it stops at red line. Even if I change to "Activesheet.paste" it doesn't work.

May you guys help me?

Thanks a lot,
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
You are clearing the clipboard with the actions you do after the copy. Try:
Code:
Dim wbk as Workbook
set wbk = Workbooks.Open ("C:\FX.xls")
wbk.Sheets.Add.Name = "Exchange"
Workbooks("C:\job.xls").Sheets("Report").Range("A1:H1").Copy destination:=wbk.sheets("Exchange")Range("A1")
Columns("A:A").ColumnWidth = 16
Columns("B:D").ColumnWidth = 23
Columns("E:F").ColumnWidth = 15
Columns("G:G").ColumnWidth = 24
Columns("H:H").NumberFormat = "m/d/yyyy"
 
Upvote 0
Try

Code:
Workbooks.Open ("C:\FX.xls")
Sheets.Add.Name = "Exchange"
Workbooks("job.xls").Sheets("Report").Range("A1:H1").Copy Destination:=Workbooks("FX.xls").Sheets("Exchange").Range("A1")
 
Upvote 0
Changing sheets erases the clipboard? If you could explain this a bit more. I normally just fiddle with my code until it lets me paste.

This could save me some time in the future.
 
Upvote 0
No, it is opening a workbook that clears the clipboard. You need to have both workbooks open before copying and pasting between them.
 
Upvote 0
Does it erase if I open ANY workbook? I.E. if I want to clear the clipboard, could I open a blank workbook and close it?
 
Upvote 0

Forum statistics

Threads
1,224,574
Messages
6,179,629
Members
452,933
Latest member
patv

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