View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default how to copy formula without changing reference

Sub CopyFormulas()
Dim rng1 as Range, rng2 as Range, i as Long
on Error Resume Next
set rng1 = Application.InputBox("Select cells to copy using mouse",type:=8)
On Error goto 0
if rng1 is nothing then
msgbox "You selected nothing"
exit sub
end if

on Error Resume Next
set rng2 = Application.InputBox("Select top cell to paste tousing
mouse",type:=8)
On Error goto 0
if rng2 is nothing then
msgbox "You selected nothing"
exit sub
end if

i = 1
for each cell in rng1
rng2(i).Formula = cell.formula
i = i + 1
Next

End Sub

If you want them spaced out like the original selections, that would take
more work.

--
Regards,
Tom Ogilvy



"jiang" wrote in message
...
btw, tom

what I want is,
first I could select many cells, not necessary together,

Then kind of copy formula from these cells

last I go to a new position or sheet, then 'paste' formula from selected
cells. the result is , make a new copy (for instance, the cell is exactly
same including formula), but in Excel no such function.