Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hello All,
Just starting this vba thing and I've hit a prob. I've got a sub that asks some questions and if the response is correct it should open a userform for further data: msg = MsgBox("Are the savings over £6000?", vbYesNo) If Response = vbYes Then 'the user chose yes Tariff_HB.Show 'bring the form on screen End If If Response = vbNo Then 'the user chose no Exit Sub 'get out of it Which all seems to look OK (to me!) but the form doesn't load... What's wrong? Thanks in advance. Martin |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Martin,
Your code should be : Response= MsgBox("Are the savings over £6000?", vbYesNo) HTH "Martin" wrote: Hello All, Just starting this vba thing and I've hit a prob. I've got a sub that asks some questions and if the response is correct it should open a userform for further data: msg = MsgBox("Are the savings over £6000?", vbYesNo) If Response = vbYes Then 'the user chose yes Tariff_HB.Show 'bring the form on screen End If If Response = vbNo Then 'the user chose no Exit Sub 'get out of it Which all seems to look OK (to me!) but the form doesn't load... What's wrong? Thanks in advance. Martin |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
You're not putting the return value from MsgBox into your Response
variable, so you'll never have Response=vbYes. Try: Dim Response As Long Response = MsgBox("Are the savings over £6000?", vbYesNo) If Response = vbNo Then Exit Sub Tariff_HB.Show In article , "Martin" wrote: Hello All, Just starting this vba thing and I've hit a prob. I've got a sub that asks some questions and if the response is correct it should open a userform for further data: msg = MsgBox("Are the savings over £6000?", vbYesNo) If Response = vbYes Then 'the user chose yes Tariff_HB.Show 'bring the form on screen End If If Response = vbNo Then 'the user chose no Exit Sub 'get out of it Which all seems to look OK (to me!) but the form doesn't load... What's wrong? Thanks in advance. Martin |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
To add to what Toppers wrote, it's often desirable to make forms modal.
a more formal way to write the sub would be: Dim frm As Tariff_HB If MsgBox("Are the savings over £6000?", vbYesNo) = vbYes Then Set frm = New Tariff_HB Tariff_HB.Show vbModal Set frm = Nothing End If |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hello,
Ah, it all becomes clear! Many thanks to you both you've been very helpful. Martin wrote in message ups.com... To add to what Toppers wrote, it's often desirable to make forms modal. a more formal way to write the sub would be: Dim frm As Tariff_HB If MsgBox("Are the savings over £6000?", vbYesNo) = vbYes Then Set frm = New Tariff_HB Tariff_HB.Show vbModal Set frm = Nothing End If |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Trying to make a list/form Newbie!!!!! | Excel Discussion (Misc queries) | |||
Show Data Form | Excel Programming | |||
Help! Animated gif-image in form does not show animation when form loaded | Excel Programming | |||
Trouble with filtering form - newbie | Excel Programming | |||
Show' Read Only' On A Form | Excel Programming |