SonicBoomGolf
Active Member
- Joined
- Aug 7, 2004
- Messages
- 325
I am trying to use VBA to Loop a Goal Seek, but for some reason it is not working. Below is my code.
Do
If Not Selection.Value > "" Then Exit Do
Range("aa2").GoalSeek Goal:=44500, ChangingCell:=Range("z2")
Loop
End Sub
In the sample below, column T is the original figure and column Z is the Goal Seek Result. When I run the "Range("aa2").GoalSeek Goal:=44500, ChangingCell:=Range("z2")" portion of the above code it works, but I cannot get it to loop to the bottom of my data like I want. So basically I am having trouble with the code looping to the bottom of my data. Any ideas?
Do
If Not Selection.Value > "" Then Exit Do
Range("aa2").GoalSeek Goal:=44500, ChangingCell:=Range("z2")
Loop
End Sub
In the sample below, column T is the original figure and column Z is the Goal Seek Result. When I run the "Range("aa2").GoalSeek Goal:=44500, ChangingCell:=Range("z2")" portion of the above code it works, but I cannot get it to loop to the bottom of my data like I want. So basically I am having trouble with the code looping to the bottom of my data. Any ideas?
Sylvester - Trans Cost Analysis.xls | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
T | U | V | W | X | Y | Z | AA | |||
1 | NumberofChepPallets | Avg.CHEPWeight | TotalPalletWeight | TotalPalletWeightPlusProductWeight | ExcessWeight | AveWeight/Pallet | NumberofChepPallets | TotalWeight | ||
2 | 25 | 65 | 1625 | 72393 | 27,893 | 2,831 | 15 | 44,500 | ||
3 | 29 | 65 | 1885 | 49713 | 5,213 | 1,649 | 29 | 49,713 | ||
4 | 29 | 65 | 1885 | 48397 | 3,897 | 1,604 | 29 | 48,397 | ||
5 | 29 | 65 | 1885 | 48247 | 3,747 | 1,599 | 29 | 48,247 | ||
6 | 27 | 65 | 1755 | 48135 | 3,635 | 1,718 | 27 | 48,135 | ||
7 | 27 | 65 | 1755 | 48046 | 3,546 | 1,714 | 27 | 48,046 | ||
8 | 27 | 65 | 1755 | 47949 | 3,449 | 1,711 | 27 | 47,949 | ||
9 | 26 | 65 | 1690 | 47915 | 3,415 | 1,778 | 26 | 47,915 | ||
10 | 25 | 65 | 1625 | 47894 | 3,394 | 1,851 | 25 | 47,894 | ||
11 | 27 | 65 | 1755 | 47889 | 3,389 | 1,709 | 27 | 47,889 | ||
12 | 27 | 65 | 1755 | 47856 | 3,356 | 1,707 | 27 | 47,856 | ||
Sylvester |