W webmax Member Nov 21, 2014 #1 Hi I am attaching the same excel file in that i make cell C8 as Zero by changing E8 Column For that i have to change from C8 to C22 cell as Zero by Changing the E8 to E22 I Need the macro Attachments test.xlsx 9.4 KB · Views: 7
Hi I am attaching the same excel file in that i make cell C8 as Zero by changing E8 Column For that i have to change from C8 to C22 cell as Zero by Changing the E8 to E22 I Need the macro
Hui Excel Ninja Staff member Nov 21, 2014 #2 Webmax Firstly The logic above does not make sense C8: =A8+B8 has no connection to E8 A8 and B8 are both values What is F8 ? If you want C8 to be zero which of A8 or B8 do you want changed ? If you want to make C8 = 0 by changing B8 use the following: Code: For i = 8 To 22 Range("C" & i).GoalSeek Goal:=0, ChangingCell:=Range("B" & i) Next If you want to make C8 = 0 by changing A8 use the following: Code: For i = 8 To 22 Range("C" & i).GoalSeek Goal:=0, ChangingCell:=Range("A" & i) Next Can you please clarify your requirements Last edited: Nov 21, 2014
Webmax Firstly The logic above does not make sense C8: =A8+B8 has no connection to E8 A8 and B8 are both values What is F8 ? If you want C8 to be zero which of A8 or B8 do you want changed ? If you want to make C8 = 0 by changing B8 use the following: Code: For i = 8 To 22 Range("C" & i).GoalSeek Goal:=0, ChangingCell:=Range("B" & i) Next If you want to make C8 = 0 by changing A8 use the following: Code: For i = 8 To 22 Range("C" & i).GoalSeek Goal:=0, ChangingCell:=Range("A" & i) Next Can you please clarify your requirements