Consulting

Results 1 to 5 of 5

Thread: How can I make this work

  1. #1
    VBAX Expert
    Joined
    Apr 2007
    Location
    Orlando, FL
    Posts
    751
    Location

    How can I make this work

    I have this

    [VBA]Sub SaveForm()
    Dim res As String
    ActiveWorkbook.Save
    res = MsgBox("Does this Spreadsheet need a Signature?", vbYesNoCancel, "Signature Request")

    Select Case res

    Case vbYes

    FrmSignatureNames.Show


    Case vbNo

    If Range("AA1").Value = "Available" Then
    Call SaveAvailable

    Else
    If Range("AA2").Value = "Retire" Then
    Call SaveRetire

    '-------------------------------------------------------------------------------------------------
    '-------------------------------------------------------------------------------------------------
    Else
    If Range("AA1", "AA2").Value = "" Then
    Dim fp As String, strSaveFile As String

    FilePath = ""
    'fp = "C:\Equipment Tracking\WIP\"
    fp = "S:\Equipment Tracking\WIP\"
    Call MakeFolders(fp)
    Call MakeFolders(Range("K3") & "\")
    Call MakeFolders(Range("K5") & "\")


    Application.DisplayAlerts = False
    strSaveFile = Range("B6").Value & ".xls"
    Application.DisplayAlerts = True

    ActiveWorkbook.SaveAs FilePath & strSaveFile, xlWorkbookNormal
    FilePath = ""

    'Kill ("C:\Equipment Tracking\Needs Approval\" & Range("V1").Value & "\" & Range("B6").Value & ".xls")
    Kill ("S:\Equipment Tracking\Needs Approval\" & Range("V1").Value & "\" & Range("B6").Value & ".xls")
    End If

    ActiveWindow.SelectedSheets.PrintOut From:=1, To:=1, Copies:=1, Collate _
    :=True

    ActiveWorkbook.Save
    ActiveWorkbook.Close

    Case vbCancel

    Exit Sub

    End Select

    End Sub[/VBA]


    It's Giving Me a problem with the VbNo case I guess because I have to many If Statements.

    Is there a way I can make this work.

  2. #2
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,728
    Location
    Not tested but maybe you can try this, and fix anything that still needs fixin'


    Paul

    [vba]
    Sub SaveForm()
    Dim res As String
    ActiveWorkbook.Save
    res = MsgBox("Does this Spreadsheet need a Signature?", vbYesNoCancel, "Signature Request")

    Select Case res

    Case vbYes

    FrmSignatureNames.Show


    Case vbNo

    If Range("AA1").Value = "Available" Then
    Call SaveAvailable

    ElseIf Range("AA2").Value = "Retire" Then '<<<<<<<<<<<<<<
    Call SaveRetire

    '-------------------------------------------------------------------------------------------------
    '-------------------------------------------------------------------------------------------------
    ElseIf Range("AA1", "AA2").Value = "" Then '<<<<<<<<<<<<<<
    Dim fp As String, strSaveFile As String

    FilePath = ""
    'fp = "C:\Equipment Tracking\WIP\"
    fp = "S:\Equipment Tracking\WIP\"
    Call MakeFolders(fp)
    Call MakeFolders(Range("K3") & "\")
    Call MakeFolders(Range("K5") & "\")


    Application.DisplayAlerts = False
    strSaveFile = Range("B6").Value & ".xls"
    Application.DisplayAlerts = True

    ActiveWorkbook.SaveAs FilePath & strSaveFile, xlWorkbookNormal
    FilePath = ""

    'Kill ("C:\Equipment Tracking\Needs Approval\" & Range("V1").Value & "\" & Range("B6").Value & ".xls")
    Kill ("S:\Equipment Tracking\Needs Approval\" & Range("V1").Value & "\" & Range("B6").Value & ".xls")
    End If

    ActiveWindow.SelectedSheets.PrintOut From:=1, To:=1, Copies:=1, Collate:=True

    ActiveWorkbook.Save
    ActiveWorkbook.Close

    Case vbCancel

    Exit Sub

    End Select

    End Sub
    [/vba]

  3. #3
    VBAX Expert
    Joined
    Apr 2007
    Location
    Orlando, FL
    Posts
    751
    Location
    I am having a problem with I believe this part of the code
    [VBA]ElseIf Range("AA1", "AA2").Value = "" Then[/VBA]

    It works fine with
    [VBA]If Range("AA1").Value = "Available" Then
    Call SaveAvailable

    ElseIf Range("AA2").Value = "Retire" Then '<<<<<<<<<<<<<<
    Call SaveRetire
    [/VBA]

    But when I select No and these two value's are "" it fails. These cells have formula's in them I don't know if that would affect this from working.

  4. #4
    VBAX Expert
    Joined
    Apr 2007
    Location
    Orlando, FL
    Posts
    751
    Location
    ok it seems to work if I just eliminate the Range and just leave it with Else.

  5. #5
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,728
    Location
    I've never done it that way, but try this to see


    [VBA]
    ElseIf Range("AA1") = "" and Range(""AA2").Value = "" Then
    [/VBA]

Posting Permissions

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