MrExcel Message Board

Go Back   MrExcel Message Board > Question Forums > Excel Questions

Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only.

Reply
 
Thread Tools Display Modes
Old May 3rd, 2002, 10:06 AM   #1
chouston
Board Regular
 
Join Date: Apr 2002
Location: Arizona
Posts: 68
Default

Hi, hope you can help me on these...

1) Is it possible change the settings on the message box and input box so that the user can do other stuff when they're on screen? (i.e. mouse pointer is not an hourglass)

2) Do I need to do something special so that the Cancel button on the input box works?

Thanks in advance for any help.
chouston is offline   Reply With Quote
Old May 3rd, 2002, 10:11 AM   #2
NateO
Legend
 
NateO's Avatar
 
Join Date: Feb 2002
Location: Minneapolis, Mn, USA
Posts: 9,704
Default

1) You can manipulate the Status Bar:

Code:
Application.StatusBar = "Processing..."

to return to normal:

Application.StatusBar = False
2) The cancel button on the input box should work unless you dim the input as an object variable. In which case you need an errorhandler preceeding your inputbox statement, i.e., on error resume next.
_________________
Cheers, NateO

[ This Message was edited by: NateO on 2002-05-03 09:15 ]
NateO is offline   Reply With Quote
Old May 3rd, 2002, 10:20 AM   #3
chouston
Board Regular
 
Join Date: Apr 2002
Location: Arizona
Posts: 68
Default

1) I tried application.statusbar = false and I still can't select the spreadsheet behind the inputbox/msgbox and scroll through it.

2) I don't think I dimmed the variables as objects but here's the code:

OutDate = (DateValue(InputBox("Move out date?", "Final Billing Form")))
'If OutDate = "" Then Exit Sub
If vbCancel Then
Exit Sub
Else
End If

the 'vbcancel' part was just a guess, but it's not working.

btw thanks for your help
chouston is offline   Reply With Quote
Old May 3rd, 2002, 10:29 AM   #4
jlarson
New Member
 
Join Date: May 2002
Posts: 5
Default

I'm not sure about message box and input box. With userforms, use vbModeless to allow you to work "behind" the userform.

Example:

userform1.Show vbModeless
jlarson is offline   Reply With Quote
Old May 3rd, 2002, 10:53 AM   #5
waderw
Board Regular
 
Join Date: Apr 2002
Posts: 85
Default

try this:

If OutDate = vbnullstring or vbNo Then
Exit Sub
else
'do something here
end if
waderw is offline   Reply With Quote
Old May 3rd, 2002, 10:54 AM   #6
waderw
Board Regular
 
Join Date: Apr 2002
Posts: 85
Default

that will not work try:

If OutDate = vbnullstring or OutDate = vbNo Then
Exit Sub
else
'do something here
end if


waderw is offline   Reply With Quote
Old May 3rd, 2002, 11:04 AM   #7
NateO
Legend
 
NateO's Avatar
 
Join Date: Feb 2002
Location: Minneapolis, Mn, USA
Posts: 9,704
Default

Use the statusbar at the beginning and end of your code, like:

Code:
Sub test()
Application.StatusBar = "Processing...."
OutDate = Application.InputBox(prompt:="Move out date?", _
Title:="Final Billing Form", Type:=1)
Application.StatusBar = False
End Sub
If there is any piece of your macro that states dim outdate, you'll need an errorhandler, e.g.,

Code:
Sub test()
Application.StatusBar = "Processing...."
on error resume next
OutDate = Application.InputBox(prompt:="Move out date?", _
Title:="Final Billing Form", Type:=1)
Application.StatusBar = False
End Sub
Hope this helps.
__________________
Regards,
Nate Oliver
Microsoft Excel MVP
Nate's Excel Blog
NateO is offline   Reply With Quote
Old May 3rd, 2002, 11:09 AM   #8
NateO
Legend
 
NateO's Avatar
 
Join Date: Feb 2002
Location: Minneapolis, Mn, USA
Posts: 9,704
Default

You want to select a date from a cell?

Try this:

Code:
Sub tst()
Dim outdate As Range
Application.StatusBar = "Processing...."
On Error GoTo errorhandler
Set outdate = Application.InputBox(prompt:="Move out date?", _
Title:="Final Billing Form (Click on a Cell)", Type:=8)
'do stuff with 'outdate.Value' e.g., msgbox outdate.value
errorhandler:
Application.StatusBar = False
End Sub
Hope this helps.

_________________
Cheers, NateO

[ This Message was edited by: NateO on 2002-05-03 10:09 ]
NateO is offline   Reply With Quote
Old May 3rd, 2002, 11:36 AM   #9
chouston
Board Regular
 
Join Date: Apr 2002
Location: Arizona
Posts: 68
Default

Hi, thanks for all your help so far but I'm still having trouble debugging this. Being able to access the screen behind the msgbox/inputbox is not that big of a deal so I'm dropping that, but I'm still having trouble with error-trapping. If the user inputs everything correctly, everything works fine, including the cancel buttons. However, if someone enters an invalid unit, the correct error message gets displayed "Invalid unit...", and the sub starts over, but this time when cancel is chosen, or vbno for "Do you want to print?", then, instead of exiting properly, it continues to cycle to the beginning and ignore cancel buttons.

I know this is alot to ask but if any of you have the time/patience/saintlyness to check out my code I would very much appreciate it. btw thanks to NateO, Jlarson, and waderw for your help so far!

Sub finalbill()

Dim unit
'Dim OutDate As Date


'Application.StatusBar = "Processing..."
Application.ScreenUpdating = False


'prompt for unit number
unit = (CVar(InputBox("Enter Unit #:", "Final Billing Form")))
If unit = "" Then Exit Sub



'find row for that unit number
With Sheets("Ridge Download").Range("B43:B422")
On Error Resume Next
resrow = .Find((unit), lookat:=xlWhole).Row
If resrow = Empty Then
MsgBox ("Please enter a valid unit number.")
finalbill
Else
End If
End With



'pulls values from sheet
res = ActiveWorkbook.Sheets("Ridge Download").Cells(resrow, 6)
begdate = ActiveWorkbook.Sheets("Ridge Download").Cells(resrow, 9)
wat = ActiveWorkbook.Sheets("Ridge Download").Cells(resrow, 12)
sew = ActiveWorkbook.Sheets("Ridge Download").Cells(resrow, 13)
tras = ActiveWorkbook.Sheets("Ridge Download").Cells(resrow, 14)
fee = ActiveWorkbook.Sheets("Ridge Download").Cells(resrow, 15)
monthdays = ActiveWorkbook.Sheets("Ridge Download").Cells(12, 11)
acctnum = ActiveWorkbook.Sheets("Ridge Download").Cells(resrow, 1)
thedate = Date
feet = ActiveWorkbook.Sheets("Ridge Download").Cells(resrow, 27)
unitype = ActiveWorkbook.Sheets("Ridge Download").Cells(resrow, 25)
rooms = ActiveWorkbook.Sheets("Ridge Download").Cells(resrow, 26)
watunit = ActiveWorkbook.Sheets("Ridge Download").Cells(resrow, 45)
sewunit = ActiveWorkbook.Sheets("Ridge Download").Cells(resrow, 46)
trashunit = ActiveWorkbook.Sheets("Ridge Download").Cells(resrow, 47)
feeunit = ActiveWorkbook.Sheets("Ridge Download").Cells(resrow, 48)
watrate = ActiveWorkbook.Sheets("Ridge Download").Range("H3")
sewrate = ActiveWorkbook.Sheets("Ridge Download").Range("H4")
trashrate = ActiveWorkbook.Sheets("Ridge Download").Range("H5")
feerate = ActiveWorkbook.Sheets("Ridge Download").Range("H6")

'if user enters a vacant unit
'If ActiveWorkbook.Sheets("Ridge Download").Cells(resrow, 3) = "" Then
' MsgBox ("Unit not occupied!")
' finalbill
'Else
'End If
If wat = "" Then
MsgBox ("Unit was not occupied")
finalbill
Else
End If




'prompt for move-out date
OutDate = (DateValue(InputBox("Move out date?", "Final Billing Form")))
If OutDate = vbNullString Or OutDate = vbNo Then
Exit Sub
Else
End If


'perform calcs
Days = OutDate - begdate
prorate = Days / monthdays

If wat <> "" Then water = wat * prorate
If sew <> "" Then sewer = sew * prorate
If tras <> "" Then trash = tras * prorate
If fee <> "" Then adminfee = fee

FinalAmt = water + sewer + trash + adminfee



'build message
Message = res
Message = Message & vbCrLf & "Unit #:" & vbTab & vbTab & unit
Message = Message & vbCrLf & "Move-Out Date" & vbTab & OutDate
Message = Message & vbCrLf & "Days Occupied" & vbTab & Days
Message = Message & vbCrLf & "Water" & vbTab & vbTab & Format(water, "$##.#0")
Message = Message & vbCrLf & "Sewer" & vbTab & vbTab & Format(sewer, "$##.#0")
Message = Message & vbCrLf & "Trash" & vbTab & vbTab & Format(trash, "$##.#0")
Message = Message & vbCrLf & "Admin Fee" & vbTab & Format(adminfee, "$##.#0")
Message = Message & vbCrLf & "Amt. Due" & vbTab & vbTab & Format(FinalAmt, "$##.#0")
Message = Message & vbCrLf & vbCrLf & "Print Final Bill?"



'displays and prompts for printing
Application.ScreenUpdating = True
ActiveWorkbook.Sheets("Ridge Download").Cells(resrow, 6).Select
ans = MsgBox(Message, vbYesNo, "Final Billing Form")
If ans = vbYes Then

Application.ScreenUpdating = False
ActiveWorkbook.Sheets("final bill").Select

'formats bill template
ActiveWorkbook.Sheets("final bill").Range("C13") = res
ActiveWorkbook.Sheets("final bill").Range("I14") = unit
ActiveWorkbook.Sheets("final bill").Range("Q28") = OutDate
ActiveWorkbook.Sheets("final bill").Range("M28") = acctnum
ActiveWorkbook.Sheets("final bill").Range("N28") = begdate
ActiveWorkbook.Sheets("final bill").Range("O28") = OutDate
ActiveWorkbook.Sheets("final bill").Range("b28") = unitype
ActiveWorkbook.Sheets("final bill").Range("g28").Value = rooms
ActiveWorkbook.Sheets("final bill").Range("k28").Value = feet
ActiveWorkbook.Sheets("final bill").Range("b37").Value = watunit * prorate
ActiveWorkbook.Sheets("final bill").Range("b38").Value = sewunit * prorate
ActiveWorkbook.Sheets("final bill").Range("b39").Value = trashunit * prorate
ActiveWorkbook.Sheets("final bill").Range("b40").Value = feeunit
ActiveWorkbook.Sheets("final bill").Range("i37").Value = watrate
ActiveWorkbook.Sheets("final bill").Range("i38").Value = sewrate
ActiveWorkbook.Sheets("final bill").Range("i39").Value = trashrate
ActiveWorkbook.Sheets("final bill").Range("i40").Value = feerate
ActiveWorkbook.Sheets("final bill").Range("k32").Value = Days

'print and return home
ActiveWindow.SelectedSheets.PrintOut Copies:=1
ActiveWorkbook.Sheets("Ridge Download").Select
Application.ScreenUpdating = True
ActiveWorkbook.Sheets("Ridge Download").Range("A42").Select


Else
End If

'Application.StatusBar = False

End Sub

p.s. how do you paste your code with the smaller font?
chouston is offline   Reply With Quote
Old May 3rd, 2002, 12:38 PM   #10
NateO
Legend
 
NateO's Avatar
 
Join Date: Feb 2002
Location: Minneapolis, Mn, USA
Posts: 9,704
Default

Golly gee whiz this is finicky, I broke down the error trapping into two procedures, you may need to play with this. The way you've defined your input box creates a situaiton where cancel or a bad input creates a null value, you can't distinguish between the two . So here's the code:

Code:
Sub finalbill()
On Error GoTo errorhandler1
outdate = (DateValue(InputBox("Move out date?", "Final Billing Form")))
MsgBox outdate
Exit Sub
'rest of your code
errorhandler1:
Call hndle
End Sub

Sub hndle()
Select Case MsgBox("Task aborted." & Chr(13) & Chr(13) & _
    "   If you meant to ""Cancel"" click ""Yes.""" & Chr(13) & Chr(13) & _
    "   If you inadvertantly botched the format click ""No.""" & Chr(13), vbYesNo)
Case vbYes
Case vbNo
Call finalbill
End Select
End Sub


Click on edit and notice the code and /code in brackets at the beg and end of my codes. 'Tis BB code. Hope this helps.

_________________
Cheers, NateO

[ This Message was edited by: NateO on 2002-05-03 11:41 ]
NateO is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT -4. The time now is 06:57 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
All contents Copyright 1998-2012 by MrExcel Consulting.
diabetic desserts recipes recipes Diabetic Soups Holiday Pizza Recipes Popcorn Recipes Recipes For Microwave Pasta Recipes Casserole Recipes Chili Recipes Curry Recipes Crockpot Recipes Apples Recipes Bread Recipes Vegetarian Recipes Vegetable recipes Desserts Recipes Appetizers Ethnic Recipes Meat Dishes Barbecue Recipes Sauces Recipes Marinade Recipes Low Fat Recipes Frugal Gourmet Kitchen Classics Recipes On The Grill Cook Books Seafood Recipes Cajun Recipes Breads Low Fat Low Fat Breads Bread Machine Recipes Yeast Breads Quick Breads Fat Free Vegetarian Salad Recipes Eggplant Recipes Radish Recipes Tomato Recipes Jalapeno Recipes Potato Recipes Lettuce Recipes Cabbage Recipes Beans Ambrosia Recipes Biscotti Recipes Desserts Low Fat Cookie Recipes Cheesecake Recipes Cake Recipes Pie Recipes Muffin Recipes Custard Recipes Best Appetizers Appetizers Low Fat Salsa Recipes Dip Recipes International Recipes Afghan Recipes Alaska Recipes French Recipes German Recipes Greek Recipes Italian Recipes Spanish Recipes Thai Recipes Korean Recipes Chinese Recipes Mexican Recipes Indian Recipes Beef Recipes Pork Pork & Ham Pork Butts Pork Chop Recipes Pork Ribs Rulled Pork Poultry Recipes Stews Recipes Ground Beef Barbecue Grill Barbecue Smoker All Purpose Sauce BBQ Sauce Barbecue Sauce Carolina BBQ Sauce Pickle Recipes Marinades Smoking Low Fat Appetizers & Dips Low Fat Breakfast Low Fat Cakes Low Fat Cheesecakes Low Fat Cookies Low Fat Desserts Low Fat Fish & Seafood Low Fat Meats Low Fat Pasta Low Fat Pies Low Fat Salads Low Fat Sandwiches Low Fat Sauces & Condiments Low Fat Sides Low Fat Soups Low Fat Vegetarian Baker's Dozen Taste of Home Recipe Book Bon Appetit Cookbook Blacktie Cookbook Buster Cook Book Cookbook USA Cook Book Cook Book Sara's Cookbook Sara's Cookbook Appetizers and Dips Poultry recipes Diabetic recipes Holiday recipes Miscellaneous recipes 110 recipes 1986 Usenet cookbook 2900 recipes Cyberrealm recipes Great sysops of world Specialty recipes Ceideburg recipes Cheese recipes Chili recipes Fruits recipes Garlic recipes Great chefs of NY Londontowne recipes Raisins recipes Recipes for kids US Food Vegetarian recipes Bread recipes Drinks Meat Dishes Brisket recipes Caribou recipes Chicken recipes Filet mignons recipes Pork recipes Swordfish recipes Turkey recipes Pasta recipes Uncategorized recipes Ethnic recipes Canada recipes English recipes Ethiopia recipes Germany recipes Greece recipes Mexican recipes Philippines recipes Welsh recipes Microwave recipes Soups recipes Vegetable recipes Asparagus recipes Barley recipes Brown rice recipes Lentil recipes Mushrooms recipes Salads recipes Wild rice Desserts recipes Cakes recipes Chocolate recipes Cookies recipes Ice cream recipes