Macros without buttons

imported_unknown

Active Member
Joined
Jan 13, 2002
Messages
424
Hey gang,

I'm still new to macros so I was wondering if anyone could help me out.

I've recorded a macro and would like to attribute it to a cell that has text writing in it. I do not want to attribute it to a button.

Is this possible, if so, how?

Thanks in advance.
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.

lenze

Legend
Joined
Feb 18, 2002
Messages
13,690
Do you want to run the macro when the cell is selected, or when it changes?
 

imported_unknown

Active Member
Joined
Jan 13, 2002
Messages
424
I want to run it when the cell is selected.
I am looking at another spreadsheet that does exactly what I want to do, but I can't find any of the macros in it.

I basically want to click the text in the cell and jump to specific part of the spreadsheet.

Is there a command I'm missing? In the spreadsheet that I'm looking at, it looks like a macro.

Thanks for the help!
 

lenze

Legend
Joined
Feb 18, 2002
Messages
13,690
Open up your WorkBook and right click on the Sheet Tab. Choose View Code. Enter this code
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Address<> "$A$1" Then Exit Sub
'Put your code here
End Sub

Adjust address as needed

HTH
This message was edited by lenze on 2002-10-03 16:55
 

Richie(UK)

MrExcel MVP
Joined
May 17, 2002
Messages
3,329

ADVERTISEMENT

Hi Anthony,

The reason that you probably haven't seen the code for the workbook that you are looking at is that you need a worksheet event macro, ie a macro that is triggered when a certain change takes place to a worksheet.

Right-click the sheet tab for your chosen workbook and select View Code. Then paste in the following macro by way of example:<pre>
Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
Dim MyCell As Range
Set MyCell = Worksheets(1).Cells(10, 1)
If Target.Address = MyCell.Address Then MsgBox "You selected A10!"
End Sub</pre>

Simply replace the example code with your own code. Any problems - repost with the code you are using and a description of the problem.

HTH

EDIT: Sorry lenze - busy drafting a reply and didn't refresh to check for further posts.

_________________<font color="blue"> «««<font color="red">¤<font color="blue"><font size=+1>Richie</font><font color="red">¤<font color="blue"> »»»</font>

caffeine_sample.gif
</gif>
This message was edited by Richie(UK) on 2002-10-03 17:13
 

lenze

Legend
Joined
Feb 18, 2002
Messages
13,690
By the way, if all you want to do is jump to another location in the workbook, why not just use a hyperlink?
 

Forum statistics

Threads
1,144,148
Messages
5,722,779
Members
422,457
Latest member
Mrmuskins

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
Top