Quote:
quote:Originally posted by mjppaba
Sub myMacro()
Dim myColDSum
Dim myColDMax
Dim myColDNewMax
myColDSum = WorksheetFunction.Sum(Range("D:D"))
myColDMax = WorksheetFunction.Max(Range("D:D"))
If myColDSum <> 100 Then
myColDNewMax = (100 - myColDSum) + myColDMax
End If
Range("D:D").Select
Selection.Find(What:=myColDMax, After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False).Activate
ActiveCell.Value = myColDNewMax
Range("D1").Select
End Sub
|
Thank you very much, I'm grateful. One thing popped up though if the sum of the numbers equaled 100 it would than put a blank in the cell so all i did was move the End If a little further down in order to skip the search process as it wasn't needed.
Sub myMacro()
Dim myColDSum
Dim myColDMax
Dim myColDNewMax
myColDSum = WorksheetFunction.Sum(Range("D:D"))
myColDMax = WorksheetFunction.Max(Range("D:D"))
If myColDSum <> 100 Then
myColDNewMax = (100 - myColDSum) + myColDMax
Range("D:D").Select
Selection.Find(What:=myColDMax, After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False).Activate
ActiveCell.Value = myColDNewMax
End If
Range("D1").Select
End Sub
Thanks again for the help. I've been learning a lot from these code snippets.
Thanks,
Keith