Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Yes / No - Goto VBA


Hi all,

So I've got the following code that brings up a message box when
someone inputs something into cells G5:G350.

Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As
Range)
Select Case Sh.Name
Case "Programme"
If Not Intersect(Target, Range("G5:G350")) Is Nothing Then
Range("G10").Activate
MsgBox "Now please fill in Component information", vbInformation, "Next
Step!"
End If


End Select
End Sub

I've now been asked to extend this slightly further so that when the
message box comes up it gives a yes/no option (vbYesNo). This I can do
- what I haven't quite sussed is how, when the 'Yes' is pressed to take
the user to another worksheet entitled "Components", and to keep them in
the same worksheet when they press 'No'. Any tips on how this can be
achieved?

TIA,

SamuelT


--
SamuelT
------------------------------------------------------------------------
SamuelT's Profile: http://www.excelforum.com/member.php...o&userid=27501
View this thread: http://www.excelforum.com/showthread...hreadid=545056

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 216
Default Yes / No - Goto VBA

Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As
Range)
Dim ans As Long
Select Case Sh.Name
Case "Programme"
If Not Intersect(Target, Range("G5:G350")) Is Nothing Then
Range("G10").Activate
ans = MsgBox "Now please fill in Component information", _
vbYesNo + vbInformation, "Next Step!"
If ans = vbYes Then Worksheets("Components").Activate
End If


--
HTH

Bob Phillips

(remove xxx from email address if mailing direct)

"SamuelT" wrote in
message ...

Hi all,

So I've got the following code that brings up a message box when
someone inputs something into cells G5:G350.

Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As
Range)
Select Case Sh.Name
Case "Programme"
If Not Intersect(Target, Range("G5:G350")) Is Nothing Then
Range("G10").Activate
MsgBox "Now please fill in Component information", vbInformation, "Next
Step!"
End If


End Select
End Sub

I've now been asked to extend this slightly further so that when the
message box comes up it gives a yes/no option (vbYesNo). This I can do
- what I haven't quite sussed is how, when the 'Yes' is pressed to take
the user to another worksheet entitled "Components", and to keep them in
the same worksheet when they press 'No'. Any tips on how this can be
achieved?

TIA,

SamuelT


--
SamuelT
------------------------------------------------------------------------
SamuelT's Profile:

http://www.excelforum.com/member.php...o&userid=27501
View this thread: http://www.excelforum.com/showthread...hreadid=545056



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Yes / No - Goto VBA


Hi Bob,

Thanks for that. Unfortunately, it doesn't seem to be working. I've
copied and pasted the code in and the following (red) sections seem to
be problem areas.

Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As
Range)
Dim ans As Long
Select Case Sh.Name
Case "Programme"
If Not Intersect(Target, Range("G5:G350")) Is Nothing Then
Range("G10").Activate
ans = MsgBox "Now please fill in Component information", _
vbYesNo + vbInformation, "Next Step!"
If ans = vbYes Then Worksheets("Components").Activate
End If

End Select
End Sub

Any ideas?

Thanks,

SamuelT


--
SamuelT
------------------------------------------------------------------------
SamuelT's Profile: http://www.excelforum.com/member.php...o&userid=27501
View this thread: http://www.excelforum.com/showthread...hreadid=545056

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,726
Default Yes / No - Goto VBA

Private Sub Workbook_SheetChange(ByVal Sh As Object, _
ByVal Target As Range)
Dim ans As Long
Select Case Sh.Name
Case "Programme"
If Not Intersect(Target, Range("G5:G350")) Is Nothing Then
Range("G10").Activate
ans = MsgBox("Now please fill in Component information", _
vbYesNo + vbInformation, "Next Step!")
If ans = vbYes Then Worksheets("Components").Activate
End If
End Sub

--
HTH

Bob Phillips

(replace xxxx in email address with googlemail if mailing direct)

"SamuelT" wrote in
message ...

Hi Bob,

Thanks for that. Unfortunately, it doesn't seem to be working. I've
copied and pasted the code in and the following (red) sections seem to
be problem areas.

Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As
Range)
Dim ans As Long
Select Case Sh.Name
Case "Programme"
If Not Intersect(Target, Range("G5:G350")) Is Nothing Then
Range("G10").Activate
ans = MsgBox "Now please fill in Component information", _
vbYesNo + vbInformation, "Next Step!"
If ans = vbYes Then Worksheets("Components").Activate
End If

End Select
End Sub

Any ideas?

Thanks,

SamuelT


--
SamuelT
------------------------------------------------------------------------
SamuelT's Profile:

http://www.excelforum.com/member.php...o&userid=27501
View this thread: http://www.excelforum.com/showthread...hreadid=545056



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Yes / No - Goto VBA


Thanks Bob - left an 'End Select' out on the end, but apart from tha
perfect.

Cheers,

Samuel

--
Samuel
-----------------------------------------------------------------------
SamuelT's Profile: http://www.excelforum.com/member.php...fo&userid=2750
View this thread: http://www.excelforum.com/showthread.php?threadid=54505



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
? IF & GOTO ? Karen D Excel Worksheet Functions 17 September 2nd 09 10:58 PM
? IF and GOTO ? Karen D Excel Worksheet Functions 2 September 1st 09 07:57 PM
If.....Then GoTo....... Alec H Excel Discussion (Misc queries) 4 February 22nd 06 02:42 PM
On Error Goto doesn't goto Paul Excel Programming 1 October 15th 04 03:51 PM
On Error Goto doesn't goto Paul Excel Programming 0 October 15th 04 03:05 PM


All times are GMT +1. The time now is 11:59 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"