copy sect. of 1 wkb and paste to another macro..simple?

adelene

New Member
Joined
Jul 1, 2004
Messages
28
Hi,

I've recorded a macro to follow simple steps of copying a part of a spreadsheet which has been filtered.

than to open a new workbook and dump it into worksheet 1 of A2..

simple enough, and it records no problems.

but when i attach this code to a button on the worksheet, i get error when it tries to opne a workbook and paste into A2...

the specific code of error is in bold? why? i altered to make it sheet("Sheet1").Active or something like that as i thought maybe to do with sheet not active or workbook keeps changing as if the user ran it again, it won't be workbook1 that it paste into as if its already used, it would be workbook2 (will the below still work) and can somoene help with the error in bold?


ActiveWindow.SmallScroll Down:=-6
With Application
.Calculation = xlManual
.MaxChange = 0.001
End With
ActiveWorkbook.PrecisionAsDisplayed = False
Range("K6:L6").Select
Range(Selection, Selection.End(xlDown)).Select
ActiveWindow.SmallScroll Down:=6
Selection.Copy
ActiveWindow.SmallScroll Down:=-15
Workbooks.Add
Sheets("Sheet1").Select
Range("A2").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Cells.Select
Cells.EntireColumn.AutoFit
Selection.ColumnWidth = 50
Range("A2:B2").Select
Selection.Font.Bold = True
Range("A1").Select
ActiveWindow.SmallScroll Down:=-9
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
umm.... i'll try it again..

don't know.. throws errror at range a2 for me...

which is basically where the paste begins.. strange
 
Upvote 0

Forum statistics

Threads
1,213,506
Messages
6,114,025
Members
448,543
Latest member
MartinLarkin

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