Results 1 to 9 of 9

Thread: Microsoft VBScript compilation error: Expected end of statement. What is wrong?

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2017
    Posts
    6

    Microsoft VBScript compilation error: Expected end of statement. What is wrong?

    sInput = InputBox("Enter your name")
    a=MsgBox 1("You entered: " & sInput , 4+0 , "Is that what you want entered?")

    if a = vbyes then

    b=msgbox("Yes" , 0+16 , "Yes")

    end

  2. #2
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    5,872

    Re: Microsoft VBScript compilation error: Expected end of statement. What is wrong?

    The last line should be "end if" instead of "end"

  3. #3

    Thread Starter
    New Member
    Join Date
    May 2017
    Posts
    6

    Re: Microsoft VBScript compilation error: Expected end of statement. What is wrong?

    It still gives me the error

  4. #4
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    5,872

    Re: Microsoft VBScript compilation error: Expected end of statement. What is wrong?

    Remove the 1 before the MsgBox statement

  5. #5

    Thread Starter
    New Member
    Join Date
    May 2017
    Posts
    6

    Re: Microsoft VBScript compilation error: Expected end of statement. What is wrong?

    here is the updated code: sInput = InputBox("Enter your name")
    Excute a
    a=MsgBox("You entered: " & sInput , 4+36 , "Is that what you want entered?")

    if a = vbyes then

    b=msgbox("Yes" , 0+16 , "Yes")

    endif

    i now get this error Microsoft VBScript compilation error: Expected statement

  6. #6

    Thread Starter
    New Member
    Join Date
    May 2017
    Posts
    6

    Re: Microsoft VBScript compilation error: Expected end of statement. What is wrong?

    i also took out the execute

  7. #7
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    5,872

    Re: Microsoft VBScript compilation error: Expected end of statement. What is wrong?

    It should be "end if" not "endif"

  8. #8

    Thread Starter
    New Member
    Join Date
    May 2017
    Posts
    6

    Re: Microsoft VBScript compilation error: Expected end of statement. What is wrong?

    i got it working! Thanks for all your help.

  9. #9
    New Member
    Join Date
    Oct 2019
    Posts
    1

    Re: Microsoft VBScript compilation error: Expected end of statement. What is wrong?

    I have executed the the code as below :
    set Path="D:\temp\combined.csv";%PATH%
    Sub sbVBS_To_Delete_Multiple_Columns()
    Columns("B:U").EntireColumn.Delete
    Columns("C:AX").EntireColumn.Delete
    End Sub

    Sub AddHeaders()
    Dim headers() As Variant
    Dim ws As Worksheet
    Dim wb As Workbook

    Application.ScreenUpdating = False 'turn this off for the macro to run a little faster

    Set wb = ActiveWorkbook

    headers() = Array("Asset Name", "Private IP Address", "Software/Application", "Version", "Vendor", "Role/Purpose", "Location/BU", "Model", "Owner of Asset", "Sensitive Data Type", "Sampled ?", "Syslog Forwarding Support", "Syslog Logging Level", "Asset Value", "DB Version", "Application Version", "WEB Version", "FIM Location", "Log File Location", "Log Storage Method", "Data Store Access Logging", "Agent Type", "Agent Version", "Logging Status", "Appliance Name", "Appliance Status", "Datasource Name", "Datasource Status", "Tags")

    For Each ws In wb.Sheets
    With ws
    .Rows(1).Value = "" 'This will clear out row 1
    For i = LBound(headers()) To UBound(headers())
    .Cells(1, 1 + i).Value = headers(i)
    Next i
    .Rows(1).Font.Bold = True
    End With
    Next ws

    Application.ScreenUpdating = True 'turn it back on

    MsgBox ("Done!")
    End Sub

    I am getting compilation error as : 800A401 error
    Please let me know what have I done wrong in my code

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width