macro - how to make working for colums D:X

Z

ZEB

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) ?
 
Z

ZEB

ZEB said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top