473,325 Members | 2,792 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

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
Expand|Select|Wrap|Line Numbers
  1. Sub Auto_Open()
  2. Dim Name As String
  3. Dim P As String
  4. Dim Amount As Double
  5. Dim Cnt01 As Integer
  6. Dim Cello1 As String
  7. Dim Formula01 As String
  8. '
  9.  
  10.     For Cnt01 = 1 To 40
  11.         Cell01 = "D1"
  12.         Range(Cell01).Select
  13.         Name = InputBox("Insert Name or [EXIT] to exit")
  14.         If Name = "EXIT" Then
  15.             Exit For
  16.         End If
  17.         ActiveCell.FormulaR1C1 = Name
  18.         Cell01 = "D2"
  19.         Range(Cell01).Select
  20.         Name = InputBox("Insert Rate Amount")
  21.         Amount = Val(Name)
  22.         ActiveCell.FormulaR1C1 = Amount
  23.         Cell01 = "D3"
  24.         Range(Cell01).Select
  25.         Name = InputBox("Insert Normal Amount")
  26.         Amount = Val(Name)
  27.         ActiveCell.FormulaR1C1 = Amount
  28.         Cell01 = "D4"
  29.         Range(Cell01).Select
  30.         Name = InputBox("Insert Over Time Amount")
  31.         Amount = Val(Name)
  32.         ActiveCell.FormulaR1C1 = Amount
  33.         Cell01 = "D5"
  34.         Range(Cell01).Select
  35.         Name = InputBox("Insert Sunday Time Amount")
  36.         Amount = Val(Name)
  37.         ActiveCell.FormulaR1C1 = Amount
  38.         Cell01 = "D6"
  39.         Range(Cell01).Select
  40.         Name = InputBox("Insert Leave Bonus Amount")
  41.         Amount = Val(Name)
  42.         ActiveCell.FormulaR1C1 = Amount
  43.         Cell01 = "D7"
  44.         Range(Cell01).Select
  45.         Name = InputBox("Insert Bonus Amount")
  46.         Amount = Val(Name)
  47.         ActiveCell.FormulaR1C1 = Amount
  48.         Cell01 = "D8"
  49.         Range(Cell01).Select
  50.         Name = InputBox("Insert P.A.Y.E. Amount")
  51.         Amount = Val(Name)
  52.         ActiveCell.FormulaR1C1 = Amount
  53.         Cell01 = "D9"
  54.         Range(Cell01).Select
  55.         Name = InputBox("Insert S.I.R.A. Amount")
  56.         Amount = Val(Name)
  57.         ActiveCell.FormulaR1C1 = Amount
  58.         Cell01 = "D10"
  59.         Range(Cell01).Select
  60.         Name = InputBox("Insert U.I.F. Amount")
  61.         Amount = Val(Name)
  62.         ActiveCell.FormulaR1C1 = Amount
  63.         Cell01 = "D11"
  64.         Range(Cell01).Select
  65.         Name = InputBox("Insert Loans Amount")
  66.         Amount = Val(Name)
  67.         ActiveCell.FormulaR1C1 = Amount
  68.         Cell01 = "D12"
  69.         Range(Cell01).Select
  70.         Name = InputBox("Insert Tea Amount")
  71.         Amount = Val(Name)
  72.         ActiveCell.FormulaR1C1 = Amount
  73.         Cell01 = "D13"
  74.         Range(Cell01).Select
  75.         Name = InputBox("Insert Polis Amount")
  76.         Amount = Val(Name)
  77.         Cell01 = "D14"
  78.         Range(Cell01).Select
  79.         Name = InputBox("Insert Name or [P] to print")
  80.         If Name = "P" Then
  81.             ActiveSheet.PageSetup.PrintArea = "$A$16:$H$40"
  82.             Range("G37").Select
  83.             ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
  84.         End If
  85.         fileSaveName = Application.GetSaveAsFilename( _
  86.     fileFilter:="Text Files (*.txt), *.txt")
  87. If fileSaveName <> False Then
  88.     MsgBox "Save as " & fileSaveName
  89. End If
  90.  
  91.  Next Cnt01
  92. End Sub
Nov 2 '07 #1
5 1667
what about a click sub with "Unload Me", you just attach it to your cancel button
Nov 2 '07 #2
debasisdas
8,127 Expert 4TB
Is the Cancel button not enabled on the InputBox by default ?
Nov 2 '07 #3
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
Nov 2 '07 #4
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
Nov 2 '07 #5
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.
Nov 2 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Marc | last post by:
Hi all, I am trying to write an application where I need the ability to open an Excel spreadsheet and do basic read/write, insert rows, and hide/unhide rows. Using win32com I have been able to...
1
by: Lize | last post by:
Hi, I'm writing an ASP application to open an excel workbook, then run a macro stored in the excel file, which produces outputs that will be displayed back onto my ASP application. Now the...
2
by: Mrs Howl | last post by:
I don't know if there's even a way to do what I want. I click on a button in an Access form, and it opens an instance of Excel, and opens a workbook and runs a macro that's in it. So far, fine,...
0
by: Alex | last post by:
i have a module in Access which opens an existing Excel file and envokes a macro within the Excel file to draw graphs. now i am trying to convert the Excel macro to an Access one so that the...
0
by: jpodesta | last post by:
Hello- I am fairly new to MS Access and would like to use some macros in .xls in an Access Module. I have tried to do this on my own but failed to make it work. I have included the xls macros...
4
by: Rich Wallace | last post by:
Is there a way to open an Excel file and either respond to or supress the Macro warning window via VB.NET? Dim oExcel As Excel.Workbook Dim sFilePath As String = "C:\DailyReport.xls" oExcel...
7
by: Sanket80 | last post by:
Hi I need one small help in VB I have written a macro which produces some output and stores them in the form of an excel files (about 10 files are generated) in a particular directory in C:\....
53
by: Hexman | last post by:
Hello All, I'd like your comments on the code below. The sub does exactly what I want it to do but I don't feel that it is solid as all. It seems like I'm using some VB6 code, .Net2003 code,...
1
by: Catbkr1 | last post by:
I have to automatically create some Excel Spreadsheets based on automatically generated .CSV files that are produced overnight. Each .CSV has several columns that need to be deleted. The same...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.