View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
mmarek[_2_] mmarek[_2_] is offline
external usenet poster
 
Posts: 1
Default Formula Editing Macro

Thanks.
Here are further details on my dilemna.

Cell D4 currently has formula =c4
Cell D5 currently has formula = c6

I would like to change D4 to formula =c4+e4
I would like to change D5 to formula =c6+e5

Here is code that I have tried. Excel winds up placing the origina
formula in quote marks within the new formula, which results in #NAME
result.


Sub CellEdit()
Dim myStr As String
Dim myStr2 As String
Dim cel As Range
For Each cel In Selection
myStr = (Right(cel.Formula, Len(cel.Formula) - 1))
myStr2 = "RC[1]"
cel.Value = "=" & myStr & "+RC[1]"
Next
End Su

--
Message posted from http://www.ExcelForum.com