#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 76
Default Private Sub

Please can anybody help me check why this give Compile Error higlighting "
Private Sub CommandButton1_Click()" in yellow. the first line of the code.
please advice and appreciate your time. 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 LookupSht = Sheets("Lookup")

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

End Select

Sub BuildDetailReport(TrainingSht, PersonnelSht, LookupSht)
MsgBox "Done", , BoxTitle
End Select


End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,101
Default Private Sub

You are missing and End Sub after the End Select

"Kanmi" wrote:

Please can anybody help me check why this give Compile Error higlighting "
Private Sub CommandButton1_Click()" in yellow. the first line of the code.
please advice and appreciate your time. 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 LookupSht = Sheets("Lookup")

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

End Select

Sub BuildDetailReport(TrainingSht, PersonnelSht, LookupSht)
MsgBox "Done", , BoxTitle
End Select


End Sub

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,049
Default Private Sub

read my response in the original thread. Please stay on the original
thread - it saves time wasting for others who may not realise we have been
down this route already

In the code below you have inserted a procedure before the end sub

so please change FROM this

Set LookupSht = Sheets("Lookup2")

End Select

Sub BuildDetailReport(TrainingSht, PersonnelSht, LookupSht)
MsgBox "Done", , BoxTitle
End Select


End Sub


TO THIS
Set LookupSht = Sheets("Lookup2")

End Select

BuildDetailReport ' add your 3 parameters

End Sub

Sub BuildDetailReport(TrainingSht, PersonnelSht, LookupSht)


End Sub



In summary
your original code was missing the END SUB for the first procedure, which we
indicated that you should add. In doing so, you omitted the call to the
procedure to build the report. We suggested you do that

in the code below you MUST HAVE an End Sub AFTER the END SELECT and BEFORE
the definition for teh sub BuildDetailReport
Also , you initially had a call to this as I tried to indicate






"Mike" wrote in message
...
You are missing and End Sub after the End Select

"Kanmi" wrote:

Please can anybody help me check why this give Compile Error higlighting
"
Private Sub CommandButton1_Click()" in yellow. the first line of the
code.
please advice and appreciate your time. 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 LookupSht = Sheets("Lookup")

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

End Select

Sub BuildDetailReport(TrainingSht, PersonnelSht, LookupSht)
MsgBox "Done", , BoxTitle
End Select


End Sub


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Private Sub() - Sub() CousinExcel Excel Discussion (Misc queries) 2 January 18th 10 01:39 PM
Improve method of calling a private function in a private module XP Excel Programming 1 April 30th 08 06:41 PM
re : Possible to run private sub macros by writing another private ddiicc Excel Programming 5 August 26th 05 04:49 AM
private sub JT Excel Programming 3 June 3rd 05 10:14 PM
Private Sub Running Other Private Sub Inadvertently Ross Culver Excel Programming 2 February 10th 05 07:17 PM


All times are GMT +1. The time now is 01:40 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"