Help needed with excel macro

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Skollie
    New Member
    • Nov 2007
    • 3

    Help needed with excel macro

    Hi I need help to activate the cancel button in input box to do the comaand "EXIT" in macro here is the macro and no case sensitvityin inputboxes pls tanks
    [code=vb]
    Sub Auto_Open()
    Dim Name As String
    Dim P As String
    Dim Amount As Double
    Dim Cnt01 As Integer
    Dim Cello1 As String
    Dim Formula01 As String
    '

    For Cnt01 = 1 To 40
    Cell01 = "D1"
    Range(Cell01).S elect
    Name = InputBox("Inser t Name or [EXIT] to exit")
    If Name = "EXIT" Then
    Exit For
    End If
    ActiveCell.Form ulaR1C1 = Name
    Cell01 = "D2"
    Range(Cell01).S elect
    Name = InputBox("Inser t Rate Amount")
    Amount = Val(Name)
    ActiveCell.Form ulaR1C1 = Amount
    Cell01 = "D3"
    Range(Cell01).S elect
    Name = InputBox("Inser t Normal Amount")
    Amount = Val(Name)
    ActiveCell.Form ulaR1C1 = Amount
    Cell01 = "D4"
    Range(Cell01).S elect
    Name = InputBox("Inser t Over Time Amount")
    Amount = Val(Name)
    ActiveCell.Form ulaR1C1 = Amount
    Cell01 = "D5"
    Range(Cell01).S elect
    Name = InputBox("Inser t Sunday Time Amount")
    Amount = Val(Name)
    ActiveCell.Form ulaR1C1 = Amount
    Cell01 = "D6"
    Range(Cell01).S elect
    Name = InputBox("Inser t Leave Bonus Amount")
    Amount = Val(Name)
    ActiveCell.Form ulaR1C1 = Amount
    Cell01 = "D7"
    Range(Cell01).S elect
    Name = InputBox("Inser t Bonus Amount")
    Amount = Val(Name)
    ActiveCell.Form ulaR1C1 = Amount
    Cell01 = "D8"
    Range(Cell01).S elect
    Name = InputBox("Inser t P.A.Y.E. Amount")
    Amount = Val(Name)
    ActiveCell.Form ulaR1C1 = Amount
    Cell01 = "D9"
    Range(Cell01).S elect
    Name = InputBox("Inser t S.I.R.A. Amount")
    Amount = Val(Name)
    ActiveCell.Form ulaR1C1 = Amount
    Cell01 = "D10"
    Range(Cell01).S elect
    Name = InputBox("Inser t U.I.F. Amount")
    Amount = Val(Name)
    ActiveCell.Form ulaR1C1 = Amount
    Cell01 = "D11"
    Range(Cell01).S elect
    Name = InputBox("Inser t Loans Amount")
    Amount = Val(Name)
    ActiveCell.Form ulaR1C1 = Amount
    Cell01 = "D12"
    Range(Cell01).S elect
    Name = InputBox("Inser t Tea Amount")
    Amount = Val(Name)
    ActiveCell.Form ulaR1C1 = Amount
    Cell01 = "D13"
    Range(Cell01).S elect
    Name = InputBox("Inser t Polis Amount")
    Amount = Val(Name)
    Cell01 = "D14"
    Range(Cell01).S elect
    Name = InputBox("Inser t Name or [P] to print")
    If Name = "P" Then
    ActiveSheet.Pag eSetup.PrintAre a = "$A$16:$H$4 0"
    Range("G37").Se lect
    ActiveWindow.Se lectedSheets.Pr intOut Copies:=1, Collate:=True
    End If
    fileSaveName = Application.Get SaveAsFilename( _
    fileFilter:="Te xt Files (*.txt), *.txt")
    If fileSaveName <> False Then
    MsgBox "Save as " & fileSaveName
    End If

    Next Cnt01
    End Sub[/code]
    Last edited by debasisdas; Nov 2 '07, 11:22 AM. Reason: Formatted using code tags.
  • Tequilaman
    New Member
    • Oct 2007
    • 43

    #2
    what about a click sub with "Unload Me", you just attach it to your cancel button

    Comment

    • debasisdas
      Recognized Expert Expert
      • Dec 2006
      • 8119

      #3
      Is the Cancel button not enabled on the InputBox by default ?

      Comment

      • Skollie
        New Member
        • Nov 2007
        • 3

        #4
        Originally posted by debasisdas
        Is the Cancel button not enabled on the InputBox by default ?
        no run the macro and see what i meen pls i am a beginer learning myself help pls

        Comment

        • Skollie
          New Member
          • Nov 2007
          • 3

          #5
          Originally posted by Tequilaman
          what about a click sub with "Unload Me", you just attach it to your cancel button
          Can help me with it i am a beginer and busy learning myself run the macro and see and help me make it beter and repost it pls pls help

          Comment

          • Tequilaman
            New Member
            • Oct 2007
            • 43

            #6
            Originally posted by Skollie
            Can help me with it i am a beginer and busy learning myself run the macro and see and help me make it beter and repost it pls pls help
            Have you tried to simply do 'Unload Me' before End to stop the UserForm, Process Screen or whatever you use...

            Enjoy your weekend, I'm off for a few drinks now.

            Comment

            Working...