Autofill error

christchaaya

Board Regular
Joined
Apr 5, 2013
Messages
86
Hello everyone. I'm trying to autofill column a but instead of filling it the macro is deleting the only value in it :S This is the part of the code that should autofill :


Code:
 Range("e2").Copy
    Range("a7").PasteSpecial
    Range("c" & Cells.Rows.Count).End(xlUp).Select
    ActiveCell.Offset(-1, -2).Select
    Set x = ActiveCell
    Selection.AutoFill Destination:=Range("a7:" & x.Address)

I tried it on the inmediate window and it works good till the last row.

Thank you in advance :D
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
Presumably the Selection (cell x) is empty. You are then telling Excel to AutoFill that value (empty) to a range of cells, including A7.

You generally do not need to select anything to work with it and selecting slows your code.

See if this does what you were trying to do. If not, more explanation of what you want to happen, rather that what is going wrong.
Code:
Range("E2").Copy
Range("A7").PasteSpecial
Range("A7").AutoFill Destination:=Range("A7:A" & Range("C" & Rows.Count).End(xlUp).Row - 1)
 
Upvote 0

Forum statistics

Threads
1,216,174
Messages
6,129,297
Members
449,499
Latest member
HockeyBoi

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