Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 31
Default Subtract cell formula from existing cell formula

Does anybody has a macro which would deduct the cell formula of a
selection of cells from original formula.
eg if cell A1= sum(b1:f1)
the macro would leave formula in A1 as : sum(b1:f1) - sum(b1:f1)

so that formula result of A1 would be zero

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Subtract cell formula from existing cell formula

Sub whybother()
Dim r As Range
Dim s As String, s2 As String
For Each r In Selection
s = r.Formula
s2 = WorksheetFunction.Substitute(s, "=", "")
r.Formula = s & "-" & "(" & s2 & ")"
Next
End Sub
--
Gary's Student


" wrote:

Does anybody has a macro which would deduct the cell formula of a
selection of cells from original formula.
eg if cell A1= sum(b1:f1)
the macro would leave formula in A1 as : sum(b1:f1) - sum(b1:f1)

so that formula result of A1 would be zero


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 31
Default Subtract cell formula from existing cell formula

thxs - working great !!

Gary''s Student wrote:
Sub whybother()
Dim r As Range
Dim s As String, s2 As String
For Each r In Selection
s = r.Formula
s2 = WorksheetFunction.Substitute(s, "=", "")
r.Formula = s & "-" & "(" & s2 & ")"
Next
End Sub
--
Gary's Student


" wrote:

Does anybody has a macro which would deduct the cell formula of a
selection of cells from original formula.
eg if cell A1= sum(b1:f1)
the macro would leave formula in A1 as : sum(b1:f1) - sum(b1:f1)

so that formula result of A1 would be zero



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Formula to subtract values in one cell only... neilcarden Excel Worksheet Functions 4 November 2nd 06 11:57 AM
Formula to subtract values in one cell only... neilcarden Excel Worksheet Functions 0 November 1st 06 12:14 PM
FORMULA; ADD A COLUMN, SUBTRACT 1 CELL, TAKE THE TOTAL X 10% Teresea Excel Discussion (Misc queries) 4 October 12th 06 07:37 PM
Excel: Add/subtract to existing value in same cell DOING MY BEST Excel Worksheet Functions 4 September 1st 05 08:56 PM
insert a new cell into an existing formula Debbie Excel Discussion (Misc queries) 3 March 14th 05 06:46 PM


All times are GMT +1. The time now is 01:48 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"