Approve message box but by the approver

Learner VBA

New Member
Joined
Oct 15, 2016
Messages
9
Hello All,
Thank for for helping all those who are in need!

I created a macro where it looks at the all required fields and then emails to approver. I have the same command button to trigger email function from requester to approver to final user.
My issue is I need approved message box only to show up for approver and it puts "Approved by (approver name automatically)" as there could be 5 approvers.

Here are the steps:
1. Form is being initiated by user. Macro looks at all required fields are filled and good to go
2. Form will be received by approver via email
3. Person in step # 2 needs to have message box appear with approved/rejected
4. If approved, needs "Approved by John Smith" at a certain cell
5. Form will be emailed to final user

I am layman VBA user. I create my macros using forums. I may find macro below cumbersome but I am not an expert so please excuse me...
Here is my current macro:

I need the bold stuff only to appear for approver and not for initiator
Thanks

Code:
Private Sub CommandButton1_Click()
    Set Sndr = Cells(49, 4)
    Set rcvr = Cells(54, 4)
    Set client = Cells(36, 4)
   
    If Len(Range("D6")) = 0 Then
        MsgBox "Please Enter Project Name", vbCritical
        Exit Sub
    End If
    
    If Len(Range("D7")) = 0 Then
        MsgBox "Please Enter Business Unit", vbCritical
        Exit Sub
    End If
    
    If Len(Range("D9")) = 0 Then
        MsgBox "Please Enter Start Date", vbCritical
        Exit Sub
    End If
   
    If Len(Range("I9")) = 0 Then
        MsgBox "Please Enter End Date", vbCritical
        Exit Sub
    End If
   
    If Len(Range("I11")) = 0 Then
        MsgBox "Please Enter Contract Award Value", vbCritical
        Exit Sub
    End If
    
    If Len(Range("D13")) = 0 Then
        MsgBox "Please Enter Specialty", vbCritical
        Exit Sub
    End If
     
    If Len(Range("D14")) = 0 Then
        MsgBox "Please Enter Sub-Specialty", vbCritical
        Exit Sub
    End If
     
    If Len(Range("D16")) = 0 Then
        MsgBox "Please Enter Contract Type", vbCritical
        Exit Sub
    End If
   
    If Range("D16").Value = "Other" And Range("H16").Value = "" Then
        MsgBox "Please Enter Other Description", vbCritical
        Exit Sub
    End If
   
    If Len(Range("D17")) = 0 Then
        MsgBox "Please Enter Final Customer Market Code", vbCritical
        Exit Sub
    End If
   
    If Len(Range("D18")) = 0 Then
        MsgBox "Please Enter Work being performed", vbCritical
        Exit Sub
    End If
   
    If Len(Range("D20")) = 0 Then
        MsgBox "Please Enter Project Activity", vbCritical
        Exit Sub
    End If
   
    If Len(Range("D21")) = 0 Then
        MsgBox "Please Enter Sub Project Activity", vbCritical
        Exit Sub
    End If
   
    If Len(Range("D23")) = 0 Then
        MsgBox "Please Enter Final Customer Type", vbCritical
        Exit Sub
    End If
   
    If Len(Range("D24")) = 0 Then
        MsgBox "Please Enter Final Customer Name", vbCritical
        Exit Sub
    End If
   
     If Len(Range("D25")) = 0 Then
        MsgBox "Please Enter Final Customer Field of Work", vbCritical
        Exit Sub
    End If
   
    If Len(Range("D26")) = 0 Then
        MsgBox "Please Enter Contract Type", vbCritical
        Exit Sub
    End If
   
    If Len(Range("D27")) = 0 Then
        MsgBox "Please Enter Intervention", vbCritical
        Exit Sub
    End If
   
    If Len(Range("D28")) = 0 Then
        MsgBox "Please Enter Bill Type (Pricing)", vbCritical
        Exit Sub
    End If
  
    If Len(Range("D30")) = 0 Then
        MsgBox "Please Enter Site Address", vbCritical
        Exit Sub
    End If
   
    If Len(Range("D31")) = 0 Then
        MsgBox "Please Enter City", vbCritical
        Exit Sub
    End If
   
    If Len(Range("D32")) = 0 Then
        MsgBox "Please Enter Province", vbCritical
        Exit Sub
    End If
   
    If Len(Range("H32")) = 0 Then
        MsgBox "Please Enter Postal Code", vbCritical
        Exit Sub
    End If
   
    If Len(Range("D34")) = 0 Then
        MsgBox "Please Enter Project Manager", vbCritical
        Exit Sub
    End If
   
    If Len(Range("D36")) = 0 Then
        MsgBox "Please Enter Client", vbCritical
        Exit Sub
    End If
   
    If Len(Range("D37")) = 0 Then
        MsgBox "Please Enter Client Address", vbCritical
        Exit Sub
    End If
    
    If Len(Range("D38")) = 0 Then
        MsgBox "Please Enter Province", vbCritical
        Exit Sub
    End If
     
    If Len(Range("H38")) = 0 Then
        MsgBox "Please Enter Postal Code for Client Address", vbCritical
        Exit Sub
    End If
   
    [B]Dim ApprRejQues As String
   
    ApprRejQues = MsgBox("If Approved Then Select Yes If Not Approved Select No", vbYesNo, "POF Approval")
   
         If ApprRejQues = vbYes Then
               Range("D51").Value = "APPROVED My Signature " & Format(Now(), "yyyy-MM-dd hh:mm:ss")
         Else
               Range("D51").Value = "REJECTED My Signature " & Format(Now(), "yyyy-MM-dd hh:mm:ss")
         End If[/B]
   
     Title = Sndr & "-" & Format(Now, "dd-mmm-yy") & " - " & client
    Filename = "C:\POF" & Title & ".xls"
   
    If Dir("C:\POF", vbDirectory) = vbNullString Then
      Set fs = CreateObject("Scripting.FileSystemObject")
      Set objFolder = fs.CreateFolder("C:\POF")
    End If
     
    With ActiveWorkbook
     .SaveAs Filename
     .SendMail Recipients:=rcvr, Subject:="Project Opening From " & Title
     .Close SaveChanges:=False
    End With
End Sub
 
Last edited by a moderator:

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
Do you know the windows usernames of the authorizers? If so, ENVIRON("username") returns the windows username - use it in an IF statement like this:

Code:
If ENVIRON("username") = "abcd" Then
    Dim ApprRejQues As String
   
    ApprRejQues = MsgBox("If Approved Then Select Yes If Not Approved Select No", vbYesNo, "POF Approval")
   
         If ApprRejQues = vbYes Then
               Range("D51").Value = "APPROVED " & ENVIRON("username") & " " & Format(Now(), "yyyy-MM-dd hh:mm:ss")
         Else
               Range("D51").Value = "REJECTED " & ENVIRON("username") & " " & Format(Now(), "yyyy-MM-dd hh:mm:ss")
         End If
End If

This bit of macro will now only be run for username abcd. You can use OR in the formula to build a list of multiple authorizers.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,897
Messages
6,175,271
Members
452,628
Latest member
dd2

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top