VBA help

VBAnewbie78

New Member
Joined
Apr 26, 2022
Messages
2
Office Version
  1. 365
Platform
  1. Windows
Hi all,

I am a total newbie to VBA and have been saved many a times by this forum. I recently downloaded a template for a Call Center Audit Form and am getting a Syntax error message when running it through. This is where it is stopping me: shForm.Range("L10").Value = [Today()]

VBA Code:
' Procedure to initialize the Cells, Controls

Sub InitializeSheet()

    Application.ScreenUpdating = False

    Dim shForm As Object

    Set shForm = ThisWorkbook.Sheets("Form")

    shForm.Activate

    shForm.Unprotect Password:="thedatalabs"
    
    
    'Employee & Other Details

    shForm.Range("D9:D11").Value = ""

    shForm.Range("H9:H11").Value = ""

    shForm.Range("L9:L11").Value = ""
    
    'Audit Score & Comments
    
    shForm.Range("J32:J34").Value = ""
    shForm.Range("L32:L34").Value = ""
    
    shForm.Range("J38:J42").Value = ""
    shForm.Range("L38:L42").Value = ""
    
    shForm.Range("J46:J50").Value = ""
    shForm.Range("L46:L50").Value = ""
        
    shForm.Range("J54:J55").Value = ""
    shForm.Range("L54:L55").Value = ""
    
    shForm.Range("J59:J60").Value = ""
    shForm.Range("L59:L60").Value = ""
    
    ' Feedbak/Remarks
    
    shForm.Range("B64").Value = ""

   'Adding Validation to feedback Shared Yes/No
    
    shForm.Range("L11").Select
    With Selection.Validation
        .Delete
        .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
        xlBetween, Formula1:="Yes,No"
    End With


    'Adding Validation
    'Greeting & Closing Script

    shForm.Range("J32").Select
    With Selection.Validation
        .Delete
        .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
        xlBetween, Formula1:="Yes,No,N/A"
    End With

    shForm.Range("J33").Select
    With Selection.Validation
        .Delete
        .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
        xlBetween, Formula1:="Yes,No,N/A"
    End With

    shForm.Range("J34").Select
    With Selection.Validation
        .Delete
        .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
        xlBetween, Formula1:="Yes,No,N/A"
    End With

    'Courtesy & Communication

    shForm.Range("J38").Select
    With Selection.Validation
        .Delete
        .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
        xlBetween, Formula1:="Yes,No,N/A"
    End With

    shForm.Range("J39").Select
    With Selection.Validation
        .Delete
        .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
        xlBetween, Formula1:="Yes,No,N/A"
    End With

    shForm.Range("J40").Select
    With Selection.Validation
        .Delete
        .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
        xlBetween, Formula1:="Yes,No,N/A"
    End With

    shForm.Range("J41").Select
    With Selection.Validation
        .Delete
        .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
        xlBetween, Formula1:="Yes,No,N/A"
    End With

    shForm.Range("J42").Select
    With Selection.Validation
        .Delete
        .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
        xlBetween, Formula1:="Yes,No,N/A"
    End With


    'Issue Resolution

    shForm.Range("J46").Select
    With Selection.Validation
        .Delete
        .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
        xlBetween, Formula1:="Yes,No,N/A"
    End With

    shForm.Range("J47").Select
    With Selection.Validation
        .Delete
        .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
        xlBetween, Formula1:="Yes,No,N/A"
    End With

    shForm.Range("J48").Select
    With Selection.Validation
        .Delete
        .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
        xlBetween, Formula1:="Yes,No,N/A"
    End With


    shForm.Range("J49").Select
    With Selection.Validation
        .Delete
        .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
        xlBetween, Formula1:="Yes,No,N/A"
    End With

    shForm.Range("J50").Select
    With Selection.Validation
        .Delete
        .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
        xlBetween, Formula1:="Yes,No,N/A"
    End With

    'Case Documentation

    shForm.Range("J54").Select
    With Selection.Validation
        .Delete
        .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
        xlBetween, Formula1:="Yes,No,N/A"
    End With

    shForm.Range("J55").Select
    With Selection.Validation
        .Delete
        .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
        xlBetween, Formula1:="Yes,No,N/A"
    End With

    'Process Compliance

    shForm.Range("J59").Select
    With Selection.Validation
        .Delete
        .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
        xlBetween, Formula1:="Yes,No,N/A"
    End With

    shForm.Range("J60").Select
    With Selection.Validation
        .Delete
        .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
        xlBetween, Formula1:="Yes,No,N/A"
    End With

    shForm.Range("L9").Value = Application.UserName
 [COLOR=rgb(147, 101, 184)]   [/COLOR]shForm.Range("L10").Value = [Today()]
    
    shForm.optYes = False
    shForm.optNo = False

    shForm.Activate
    shForm.Range("D9").Select

    ActiveWindow.ScrollRow = 8
    ActiveWindow.ScrollColumn = 1

   shForm.Protect Password:="thedatalabs"

    Application.ScreenUpdating = True

End Sub
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
Try . . .

VBA Code:
shForm.Range("L10").Value = [Today()]

Hope this helps!
 
Upvote 0
Try . . .

VBA Code:
shForm.Range("L10").Value = [Today()]

Hope this helps!
Thank you, it got me past that point! Now it stopped in the next line. I am actually not sure what the next 2 lines do in order to troubleshoot them.

shForm.optYes = False
shForm.optNo = False
 
Upvote 0
It's setting the value for each option button to False so that there's no option selected. Presumably, the first option button is named "optYes", and the second one "optNo". And it looks like they are probably ActiveX controls, not Form controls. Does your sheet named "Form" in fact have two ActiveX option buttons named "optYes" and "optNo"?
 
Upvote 0

Forum statistics

Threads
1,224,828
Messages
6,181,217
Members
453,024
Latest member
Wingit77

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