L
Les
I am using the code below to update sheets on beforesave. Although this is
in the Workbook command it only updates the open sheet. Is there a way to
force it to update all sheets before saving. It works if I selects all the
sheets first.
Thanks
Les
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
Dim Commvalue As Integer
Dim Poss As String
Dim Percnt As String
On Error GoTo HandleErr
Cells.Find(What:="TOTAL RPP", After:=ActiveCell, LookIn:=xlValues, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:= _
False, SearchFormat:=False).Activate
ActiveCell.Offset(, columnOffset:=2).Activate
'ActiveCell.Select
Poss = ActiveCell.Address
'Range(Poss).Select
Commvalue = Range(Poss)
ActiveCell.Offset(rowOffset:=1, columnOffset:=0).Activate
Percnt = ActiveCell.Address
Select Case Commvalue
Case Is >= 5000
Range(Percnt) = 0.15
Case Is < 50
Range(Percnt) = 0
Case Is < 1000
Debug.Print Commvalue
Range(Percnt) = 0.05
Case Is < 2000
Range(Percnt) = 0.07
Case Is < 3000
Range(Percnt) = 0.09
Case Is < 4000
Range(Percnt) = 0.11
Case Is < 5000
Range(Percnt) = 0.13
Case Else
Range(Percnt) = 0
End Select
ExitHere:
Exit Sub
HandleErr:
Select Case Err.Number
Case Else
MsgBox "This Sheet Does Not Have A Cell Titled 'Total RRP' So
Calculations Could be Incorrect Please Check After Saving", , "No RRP"
End Select
Resume ExitHere
End Sub
in the Workbook command it only updates the open sheet. Is there a way to
force it to update all sheets before saving. It works if I selects all the
sheets first.
Thanks
Les
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
Dim Commvalue As Integer
Dim Poss As String
Dim Percnt As String
On Error GoTo HandleErr
Cells.Find(What:="TOTAL RPP", After:=ActiveCell, LookIn:=xlValues, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:= _
False, SearchFormat:=False).Activate
ActiveCell.Offset(, columnOffset:=2).Activate
'ActiveCell.Select
Poss = ActiveCell.Address
'Range(Poss).Select
Commvalue = Range(Poss)
ActiveCell.Offset(rowOffset:=1, columnOffset:=0).Activate
Percnt = ActiveCell.Address
Select Case Commvalue
Case Is >= 5000
Range(Percnt) = 0.15
Case Is < 50
Range(Percnt) = 0
Case Is < 1000
Debug.Print Commvalue
Range(Percnt) = 0.05
Case Is < 2000
Range(Percnt) = 0.07
Case Is < 3000
Range(Percnt) = 0.09
Case Is < 4000
Range(Percnt) = 0.11
Case Is < 5000
Range(Percnt) = 0.13
Case Else
Range(Percnt) = 0
End Select
ExitHere:
Exit Sub
HandleErr:
Select Case Err.Number
Case Else
MsgBox "This Sheet Does Not Have A Cell Titled 'Total RRP' So
Calculations Could be Incorrect Please Check After Saving", , "No RRP"
End Select
Resume ExitHere
End Sub