![]() |
conditional message box
Hi There,
I'm trying to create a conditinal message box on open of an Excel spreadsheet. I would like it to do something like: "Do you want to update the date ranges? ", If yes then a message box to enter the ranges, if no, then another message box to say "Do you want to enter new time", if yes then a message box to enter times, if no then end. Thanks! |
conditional message box
We need much more to go on than that or your worksheet code would be: Code: -------------------- Private Sub Worksheet_SelectionChange(ByVal Target As Range) Dim Ans As String, Ans1 As String If MsgBox("Do you want to update ranges?", vbYesNo, "Range Update?") = vbYes Then Ans = Application.InputBox("Enter range in this fashion xx:xx", "Range Entry") Else If MsgBox("Do you want to enter times?", vbYesNo, "New Times") = vbYes Then Ans1 = Application.InputBox("Enter new time in this fashion xx:xx", "Time Entry") End If End If If Ans < "" Then MsgBox "the range" & Chr(34) & Ans & Chr(34) End If If Ans1 < "" Then MsgBox "the time" & Chr(34) & Ans1 & Chr(34) End If End Sub -------------------- SFConklin1;385826 Wrote: Hi There, I'm trying to create a conditinal message box on open of an Excel spreadsheet. I would like it to do something like: "Do you want to update the date ranges? ", If yes then a message box to enter the ranges, if no, then another message box to say "Do you want to enter new time", if yes then a message box to enter times, if no then end. Thanks! -- Simon Lloyd Regards, Simon Lloyd 'The Code Cage' (http://www.thecodecage.com) ------------------------------------------------------------------------ Simon Lloyd's Profile: http://www.thecodecage.com/forumz/member.php?userid=1 View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=107888 |
conditional message box
Open the Visual Basic editor. Double-click on the "ThisWorkbook" object.
Paste in the following code (be careful with line wrap). You will have to change it to suit your needs, but it gives you the idea. HTH, Eric Private Sub Workbook_Open() Dim theAns As VbMsgBoxResult Dim newDates As String Dim newTimes As String ' theAns = MsgBox("Do you want to update the Date Ranges?", _ vbQuestion + vbYesNo, "Update Date Ranges?") Select Case theAns Case vbYes ' Enter a new date range newDates = InputBox("Enter new date range (mm/dd/yyyy-mm/dd/yyyy)", "Enter New Date Range") Case vbNo ' Ask user to enter new time range theAns = MsgBox("Do you want to enter New Times?", _ vbQuestion + vbYesNo, "Enter New Times?") Select Case theAns Case vbYes ' Enter new time range newTimes = InputBox("Enter new date range (hh:mm-hh:mm)", "Enter New Time Range") Case vbNo ' Do something else or nothing... End Select ' Enter new times? End Select ' Update date ranges? End Sub -- ------------------- If toast always lands butter-side down, and cats always land on their feet, what happen if you strap toast on the back of a cat and drop it? Steven Wright (1955 - ) "SFConklin1" wrote: Hi There, I'm trying to create a conditinal message box on open of an Excel spreadsheet. I would like it to do something like: "Do you want to update the date ranges? ", If yes then a message box to enter the ranges, if no, then another message box to say "Do you want to enter new time", if yes then a message box to enter times, if no then end. Thanks! |
All times are GMT +1. The time now is 08:39 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com