Activate sheet on cell value

adamsm

Active Member
Joined
Apr 20, 2010
Messages
444
Hi anyone,

How could I write a macro code that would activate the sheet "my" if the cell A1 of the sheet as the text "My" and activate sheet "Sheet" if A1 of the active sheet has "My".

And if nothing is in cell A1. remain in the same sheet?

Any help on this would be kindly appreciated.

Thanks in advance.
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
Thanks for the help.

In the same sheet how could I create a double click event procedure so that when the cell I10 is double clicked it would copy the text "My" and paste in cell A1 of "New" sheet.

Any help would be kindly appreciated.
 
Upvote 0
Paste the following into the module of the sheet in question.

Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
If Target.Address = "$I$10" Then Sheets("New").Range("A1") = Range("A1")
End Sub
 
Upvote 0
Thanks for the code. But your code does not copy the text "My".

What may be the reason for this?
 
Upvote 0
Thanks for the code. But your code does not copy the text "My".

What may be the reason for this?

I assumed this was related to your previous question, so the code I posted copied the contents of A1 to another sheet. Try the following:

Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
If Target.Address = "$I$10" Then Sheets("New").Range("A1") = "My"
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,551
Messages
6,179,473
Members
452,915
Latest member
hannnahheileen

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top