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

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.

Peter_SSs

MrExcel MVP, Moderator
Joined
May 28, 2005
Messages
54,302
Office Version
  1. 365
Platform
  1. Windows
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)
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,163,951
Messages
5,834,548
Members
430,295
Latest member
amdis

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
Top