Make macro with loop by changing the line number

Asked

Viewed 132 times

-2

Good afternoon!

I urgently need to do a loop macro that does this:

Application.CutCopyMode = False
Application.CutCopyMode = False
Application.CutCopyMode = False
Range("BT8").GoalSeek Goal:=0, ChangingCell:=Range("AF8")
Range("F8:K8").Select
Selection.ClearContents

And in the next jump she’ll change the range to the next number.

Application.CutCopyMode = False
Application.CutCopyMode = False
Application.CutCopyMode = False
Range("BT9").GoalSeek Goal:=0, ChangingCell:=Range("AF9")
Range("F9:K9").Select
Selection.ClearContents

can help me?

1 answer

0

This is kind of a "lame" way of doing it, but it works. You just need to know the amount of boundary lines that will work.

Sub TESTE()

Dim linha As Double

    For linha = 8 To qtd_linhas

        Application.CutCopyMode = False
        Application.CutCopyMode = False
        Application.CutCopyMode = False
        Range("BT" & linha).GoalSeek Goal:=0, ChangingCell:=Range("AF" & linha)
        Range("F" & linha & ":K" & linha).Select
        Selection.ClearContents

    Next

End Sub
  • Thank you very much, I was able to adapt this structure to my reality and it worked perfectly.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.