PDA

View Full Version : [SOLVED:] Autofill NOT COPYING formula



simora
03-30-2022, 02:34 AM
I have a formula at a location on a worksheet.
When I select that cell, I want to copy that formula across the worksheet for 7 columns, but Autofill is copying the value rather than the formula.

Any ideas how to stop this and copy only the formula.

This is the code that I'm using.




Range("AU65536").End(xlUp).Offset(2, 0).Select
Selection.AutoFill Destination:=Range(ActiveCell, ActiveCell.Offset(0, 7)), Type:=xlFillDefault

Paul_Hossler
03-30-2022, 04:20 AM
Works for me

I was wondering about the



Range("AU65536").End(xlUp).Offset(2, 0).Select


since it seems to go up to the first non-blank cell, and then down 2, which seems like it'd be blank

Maybe post a small workbook

snb
03-30-2022, 05:54 AM
This functions as expected:

In A1: "=A9+12"


Sub M_snb()
Cells(1).AutoFill Cells(1).Resize(, 10)
End Sub

In J1 I find: "=J9+12"

simora
03-30-2022, 12:38 PM
Thanks for the responses:
Paul_Hossler (http://www.vbaexpress.com/forum/member.php?9803-Paul_Hossler) & snb (http://www.vbaexpress.com/forum/member.php?44644-snb)


Upon closer inspection, the formula in that cell needed to be converted.
The formula =SUM($AU$2:$AU$15) needed to be =SUM(AU2:AU15) to work as intended.

Paul_Hossler
03-30-2022, 03:29 PM
Don't you hate it when Excel does what you tell it to do, and not what you want it to do?

snb
03-31-2022, 01:37 AM
The development of an emphatic Excel version would be a challenge for AI.