Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 106
Default 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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 106
Default 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


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 106
Default 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


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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






  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 106
Default 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



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
Form keep the focus unable to get to the code - HELP! Kaz G New Users to Excel 1 January 23rd 08 06:00 PM
HELP!! Unhide Sheet with Macro and focus on other sheet [email protected] Excel Discussion (Misc queries) 2 May 23rd 06 07:17 PM
Code Only works when sheet is in focus Andibevan[_4_] Excel Programming 7 September 26th 05 04:06 PM
What is the VBA code to delete a sheet without warning message? [email protected] Excel Discussion (Misc queries) 2 August 9th 05 04:16 PM
Code Repeats Itself And Goes To Wrong Focus Minitman[_4_] Excel Programming 0 December 10th 04 06:17 PM


All times are GMT +1. The time now is 09:17 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"