![]() |
VBA code for message box and focus on a sheet
Hello people,
I have a msgbox like this. MsgBox "Please click the command button on the sheet7", vbInformation, "Author" I require the VB code for the following: If the user presses the OK button of the msbox above, then the sheet7 must be shown on the screen. (like in VB6 (for example), form7.show) what would be the VBA code for that.. please help.. Thanks, Thulasiram |
VBA code for message box and focus on a sheet
ans = MsgBox( "Please click the command button on the sheet7", _
vbInformation + vbOKCancel, "Author") if ans = vbOk then Worksheets("Sheet7").Activate end if assuming Sheet7 is the tab name. If it is the code name then Sheet7.Activate -- Regards, Tom Ogilvy "Thulasiram" wrote in message ups.com... Hello people, I have a msgbox like this. MsgBox "Please click the command button on the sheet7", vbInformation, "Author" I require the VB code for the following: If the user presses the OK button of the msbox above, then the sheet7 must be shown on the screen. (like in VB6 (for example), form7.show) what would be the VBA code for that.. please help.. Thanks, Thulasiram |
VBA code for message box and focus on a sheet
Dear Tom,
Thanks and nice to see your reply. -Thulasiram Tom Ogilvy wrote: ans = MsgBox( "Please click the command button on the sheet7", _ vbInformation + vbOKCancel, "Author") if ans = vbOk then Worksheets("Sheet7").Activate end if assuming Sheet7 is the tab name. If it is the code name then Sheet7.Activate -- Regards, Tom Ogilvy "Thulasiram" wrote in message ups.com... Hello people, I have a msgbox like this. MsgBox "Please click the command button on the sheet7", vbInformation, "Author" I require the VB code for the following: If the user presses the OK button of the msbox above, then the sheet7 must be shown on the screen. (like in VB6 (for example), form7.show) what would be the VBA code for that.. please help.. Thanks, Thulasiram |
VBA code for message box and focus on a sheet
Dear Tom,
I am facing a compile error: Variable not defined.. Variable referred here is "ans" I tried ur code in a new excel file. It works. But, I am trying to embed the code in Private Sub Workbook_SheetSelectionChange(ByVal sh As Object, ByVal target As Range) So i have to declare the variable 'ans' So I gave a declaration dim ans as boolean but in this case: Runtime error '13': Type mismatch.. Please provide your help to fix this error. Thanks, Thulasiram Thulasiram wrote: Dear Tom, Thanks and nice to see your reply. -Thulasiram Tom Ogilvy wrote: ans = MsgBox( "Please click the command button on the sheet7", _ vbInformation + vbOKCancel, "Author") if ans = vbOk then Worksheets("Sheet7").Activate end if assuming Sheet7 is the tab name. If it is the code name then Sheet7.Activate -- Regards, Tom Ogilvy "Thulasiram" wrote in message ups.com... Hello people, I have a msgbox like this. MsgBox "Please click the command button on the sheet7", vbInformation, "Author" I require the VB code for the following: If the user presses the OK button of the msbox above, then the sheet7 must be shown on the screen. (like in VB6 (for example), form7.show) what would be the VBA code for that.. please help.. Thanks, Thulasiram |
VBA code for message box and focus on a sheet
dim ans as Long
-- Regards, Tom Ogilvy "Thulasiram" wrote in message ups.com... Dear Tom, I am facing a compile error: Variable not defined.. Variable referred here is "ans" I tried ur code in a new excel file. It works. But, I am trying to embed the code in Private Sub Workbook_SheetSelectionChange(ByVal sh As Object, ByVal target As Range) So i have to declare the variable 'ans' So I gave a declaration dim ans as boolean but in this case: Runtime error '13': Type mismatch.. Please provide your help to fix this error. Thanks, Thulasiram Thulasiram wrote: Dear Tom, Thanks and nice to see your reply. -Thulasiram Tom Ogilvy wrote: ans = MsgBox( "Please click the command button on the sheet7", _ vbInformation + vbOKCancel, "Author") if ans = vbOk then Worksheets("Sheet7").Activate end if assuming Sheet7 is the tab name. If it is the code name then Sheet7.Activate -- Regards, Tom Ogilvy "Thulasiram" wrote in message ups.com... Hello people, I have a msgbox like this. MsgBox "Please click the command button on the sheet7", vbInformation, "Author" I require the VB code for the following: If the user presses the OK button of the msbox above, then the sheet7 must be shown on the screen. (like in VB6 (for example), form7.show) what would be the VBA code for that.. please help.. Thanks, Thulasiram |
VBA code for message box and focus on a sheet
Thanks Tom. Works perfectly
Tom Ogilvy wrote: dim ans as Long -- Regards, Tom Ogilvy "Thulasiram" wrote in message ups.com... Dear Tom, I am facing a compile error: Variable not defined.. Variable referred here is "ans" I tried ur code in a new excel file. It works. But, I am trying to embed the code in Private Sub Workbook_SheetSelectionChange(ByVal sh As Object, ByVal target As Range) So i have to declare the variable 'ans' So I gave a declaration dim ans as boolean but in this case: Runtime error '13': Type mismatch.. Please provide your help to fix this error. Thanks, Thulasiram Thulasiram wrote: Dear Tom, Thanks and nice to see your reply. -Thulasiram Tom Ogilvy wrote: ans = MsgBox( "Please click the command button on the sheet7", _ vbInformation + vbOKCancel, "Author") if ans = vbOk then Worksheets("Sheet7").Activate end if assuming Sheet7 is the tab name. If it is the code name then Sheet7.Activate -- Regards, Tom Ogilvy "Thulasiram" wrote in message ups.com... Hello people, I have a msgbox like this. MsgBox "Please click the command button on the sheet7", vbInformation, "Author" I require the VB code for the following: If the user presses the OK button of the msbox above, then the sheet7 must be shown on the screen. (like in VB6 (for example), form7.show) what would be the VBA code for that.. please help.. Thanks, Thulasiram |
All times are GMT +1. The time now is 06:41 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com