Thread: Command Button
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Mike H Mike H is offline
external usenet poster
 
Posts: 11,501
Default Command Button

Hi,

Looking at your code it would work but I think you have an error he-

Set PersonnelSht = Sheets("Personnel Roster2")
Set PersonnelSht = Sheets("Lookup2")

You set PersonnelSht then immediatly set it to another worksheet, do you
really mean to do that?

The other thing I would note is that it's going to call 'BuildDetailReport'
no matter what happens in the select case statement so PersonnelSht etc may
not be set.


I have no idea what the Sub BuildDetailReport does so can't comment on
whether it will work.

Mike

"Kanmi" wrote:

Please can anybody help me check why this script is not perform the right
task. whenever i run and i select OFC Then it run DOWNSTRM information. will
appreciate your advice. thanks


Private Sub CommandButton1_Click()
ask = MsgBox("Build safety report?", vbYesNo, BoxTitle)
If ask = 7 Then Exit Sub

Select Case Range("D21")
Case "DOWNSTRM":
Set TrainingSht = Sheets("Training_Progress_By_Employee")
Set PersonnelSht = Sheets("Personnel Roster")
Set PersonnelSht = Sheets("Lookup")

Case "OFC":
Set TrainingSht = Sheets("Training_Progress_By_Employee2")
Set PersonnelSht = Sheets("Personnel Roster2")
Set PersonnelSht = Sheets("Lookup2")

End Select



BuildDetailReport
MsgBox "Done", , BoxTitle
End Sub