PDA

View Full Version : Solved: copy the formula or address



Yjmmay34
07-15-2010, 12:56 AM
Hello, all. I am struggling with a problem. when i write a mcro to copy some necessary data, i hope i could copy the formula of the cell. For example, i want to copy the numbers from range(Cells(8, "AP"), Cells(500, "AP")) to range("DG8") i only know the method below:


GrandTotalRowCount = 0
i = 1
Do While ActiveSheet.Cells(i, 1) <> "Grand Total"
GrandTotalRowCount = GrandTotalRowCount + 1
i = i + 1
Loop
GrandTotalRowCount = GrandTotalRowCount - 2

range(Cells(8, "AP"), Cells(GrandTotalRowCount, "AP")).Select
selection.Copy
range("DG8").Select
selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False

but this is not what i want, even though it could still work, but there will be some cases like i suddenly found there was one number has to change in column AP, then i have to run the macro again, so i hope when i copy the data, it could store the formula in the coppied side, so when i change any number in column AP, the number in corresponding column in DG will also change automatically.
is that possible to be done? Thank you all.

Bob Phillips
07-15-2010, 07:23 AM
Can you tell us how it got solved, for the archives?

Yjmmay34
07-15-2010, 05:56 PM
Yes, xld. I use autofil method:

range("DG8").Select ActiveCell.FormulaR1C1 = "=RC[-69]" selection.AutoFill Destination:=range(Cells(8, "DG"), Cells(GrandTotalRowCount, "DG")), Type:=xlFillDefault
it can work.
Could you please do me a favor to link this address, anf help me with this problem??? Any help will be appreciated!http://www.vbaexpress.com/forum/showthread.php?t=32962