Hello All,
First of all sorry if this is answered somewhere already, but I didn't know exactly how to word it.
I am an Engineering Intern that has somehow been tasked with writing Excel Macro for the last month. I've taught myself quite a lot so far but cant figure this one out.
The first part of the macro needs to search Column Z for the next cell that is not blank nor contain a value of 12 in it and then select it. (I.E. a cell contain a value of 8 or 4.2)
The next part of the macro needs run a goal seek function changing column X until Column Z is 12
Then End itself when all of Column Z is either blank or 12
I have written This code so far and it works perfectly except it checks every single row. Which is super slow since there are currently 75500 rows at the moment and will only increase over the years.
Sub GoalSeek()
Dim i As Long
For i = 5 To 75500
If (Range("Z" & i) = 12 Or Range("Z" & i) = "") Then
Else
With Range("Z" & i)
.GoalSeek Goal:=12, ChangingCell:=Range("X" & i)
End With
End If
Next i
End Sub
My theory for writing it like this was to hopefully speed up the checking process before goal seek was used. but it is still very slow. ( I know the goal seek part will have to be slow no matter what)
This code runs when the file is saved and that will only happen if someone updates a value which will change minimum 27 rows and maximum 2145 rows, So the bulk of the 75500 rows will not need to be looked at before saving. (Which I can't seem to avoid)
Any help or lessons would be greatly appreciated, I'm a quick study most of the time, but I can't find any info on this one to study unfortunately.
First of all sorry if this is answered somewhere already, but I didn't know exactly how to word it.
I am an Engineering Intern that has somehow been tasked with writing Excel Macro for the last month. I've taught myself quite a lot so far but cant figure this one out.
The first part of the macro needs to search Column Z for the next cell that is not blank nor contain a value of 12 in it and then select it. (I.E. a cell contain a value of 8 or 4.2)
The next part of the macro needs run a goal seek function changing column X until Column Z is 12
Then End itself when all of Column Z is either blank or 12
I have written This code so far and it works perfectly except it checks every single row. Which is super slow since there are currently 75500 rows at the moment and will only increase over the years.
Sub GoalSeek()
Dim i As Long
For i = 5 To 75500
If (Range("Z" & i) = 12 Or Range("Z" & i) = "") Then
Else
With Range("Z" & i)
.GoalSeek Goal:=12, ChangingCell:=Range("X" & i)
End With
End If
Next i
End Sub
My theory for writing it like this was to hopefully speed up the checking process before goal seek was used. but it is still very slow. ( I know the goal seek part will have to be slow no matter what)
This code runs when the file is saved and that will only happen if someone updates a value which will change minimum 27 rows and maximum 2145 rows, So the bulk of the 75500 rows will not need to be looked at before saving. (Which I can't seem to avoid)
Any help or lessons would be greatly appreciated, I'm a quick study most of the time, but I can't find any info on this one to study unfortunately.