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
 

Some videos you may like

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.

Peter_SSs

MrExcel MVP, Moderator
Joined
May 28, 2005
Messages
47,926
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)
 

Watch MrExcel Video

Forum statistics

Threads
1,123,281
Messages
5,600,720
Members
414,401
Latest member
grenona2020

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