View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
ZEB ZEB is offline
external usenet poster
 
Posts: 2
Default Solution is macro - how to make working for colums D:X

ZEB wrote:


Hi,

I make macro:

Sub macro1()
Range("D6").Select
ActiveCell.FormulaR1C1 = "0"
Range("D16").Select
ActiveCell.FormulaR1C1 = "0"
While Range("D23") < 0
Range("D23").GoalSeek Goal:=0, ChangingCell:=Range("D6")
Wend

While Range("D23") 0
Range("D23").GoalSeek Goal:=0, ChangingCell:=Range("D16")
Wend

End Sub

How to make it automaticly working for range of cells (D6:X6) ,
(D16:X16) and (D23:X23) ?



Sub xx()

For a = 4 To 24

Range(Cells(6, a), Cells(6, a)).Select
ActiveCell.FormulaR1C1 = "0"

Range(Cells(16, a), Cells(16, a)).Select
ActiveCell.FormulaR1C1 = "0"


While Range(Cells(23, a), Cells(23, a)).Value < 0
Range(Cells(23, a), Cells(23, a)).GoalSeek Goal:=0,
ChangingCell:=Range(Cells(6, a), Cells(6, a))
Wend

While Range(Cells(23, a), Cells(23, a)).Value 0
Range(Cells(23, a), Cells(23, a)).GoalSeek Goal:=0,
ChangingCell:=Range(Cells(16, a), Cells(16, a))
Wend

Next a

End Sub