Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default Macro and Text

Is it possible to have the text in a cell launch a macro when clicked, or
must I use an object?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 339
Default Macro and Text


"LDanix" wrote in message
...
Is it possible to have the text in a cell launch a macro when clicked, or
must I use an object?


I think so. Isn't there an event that gets called when something has been
entered into a cell?

/Fredrik


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 184
Default Macro and Text

Hi, you could use procedures like this. It will pass the cell address,
which you could then test and run macros accordingly.

Worksheet_SelectionChange(ByVal Target As Excel.Range, Cancel As
Boolean)
Worksheet_BeforeDoubleClick(ByVal Target As Excel.Range, Cancel As
Boolean)

HTH--Lonnie M.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 184
Default Macro and Text

I think this is it:
Worksheet_Change(ByVal target As Range)

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default Macro and Text

Where do I enter all this?

"Lonnie M." wrote:

Hi, you could use procedures like this. It will pass the cell address,
which you could then test and run macros accordingly.

Worksheet_SelectionChange(ByVal Target As Excel.Range, Cancel As
Boolean)
Worksheet_BeforeDoubleClick(ByVal Target As Excel.Range, Cancel As
Boolean)

HTH--Lonnie M.




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Macro and Text

"Lonnie M." wrote in message
oups.com...
Hi, you could use procedures like this. It will pass the cell address,
which you could then test and run macros accordingly.


It passes the cell object, not its address. You can extract the value from
the object, its row, it's parent, its column, or even its address.


  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Macro and Text

An example

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

On Error GoTo ws_exit:
Application.EnableEvents = False
If Target.Address = "$F$5" Then
Call myMacro
End If

ws_exit:
Application.EnableEvents = True
End Sub

'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.


--

HTH

RP
(remove nothere from the email address if mailing direct)


"LDanix" wrote in message
...
Where do I enter all this?

"Lonnie M." wrote:

Hi, you could use procedures like this. It will pass the cell address,
which you could then test and run macros accordingly.

Worksheet_SelectionChange(ByVal Target As Excel.Range, Cancel As
Boolean)
Worksheet_BeforeDoubleClick(ByVal Target As Excel.Range, Cancel As
Boolean)

HTH--Lonnie M.




  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default Macro and Text

Which parts of the code do I need to enter the data from my sheet rather than
what is currently there?

"Bob Phillips" wrote:

An example

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

On Error GoTo ws_exit:
Application.EnableEvents = False
If Target.Address = "$F$5" Then
Call myMacro
End If

ws_exit:
Application.EnableEvents = True
End Sub

'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.


--

HTH

RP
(remove nothere from the email address if mailing direct)


"LDanix" wrote in message
...
Where do I enter all this?

"Lonnie M." wrote:

Hi, you could use procedures like this. It will pass the cell address,
which you could then test and run macros accordingly.

Worksheet_SelectionChange(ByVal Target As Excel.Range, Cancel As
Boolean)
Worksheet_BeforeDoubleClick(ByVal Target As Excel.Range, Cancel As
Boolean)

HTH--Lonnie M.





  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Macro and Text

the code was provided as a sample - you would have to alter it to meet your
needs. But the code provided goes in the sheet module as explained by Bob.

Also see Chip Pearson's page on events
http://www.cpearson.com/excel/events.htm

--
Regards,
Tom Ogilvy

"Bob Phillips" wrote in message
...
An example

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

On Error GoTo ws_exit:
Application.EnableEvents = False
If Target.Address = "$F$5" Then
Call myMacro
End If

ws_exit:
Application.EnableEvents = True
End Sub

'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.


--

HTH

RP
(remove nothere from the email address if mailing direct)


"LDanix" wrote in message
...
Where do I enter all this?

"Lonnie M." wrote:

Hi, you could use procedures like this. It will pass the cell address,
which you could then test and run macros accordingly.

Worksheet_SelectionChange(ByVal Target As Excel.Range, Cancel As
Boolean)
Worksheet_BeforeDoubleClick(ByVal Target As Excel.Range, Cancel As
Boolean)

HTH--Lonnie M.






  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Macro and Text

It was provided as an example as Tom said, but it was meant as a fairly
close example, as you said you wanted to launch a macro by clicking a cell.
All you need to do is insert it in the worksheet, as described, and change
the statement
Call myMacro
to a call to the macro that you have written, and change $F$5 to the cell
you want as you click cell (with the $ signs - very important).

--

HTH

RP
(remove nothere from the email address if mailing direct)


"LDanix" wrote in message
...
Which parts of the code do I need to enter the data from my sheet rather

than
what is currently there?

"Bob Phillips" wrote:

An example

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

On Error GoTo ws_exit:
Application.EnableEvents = False
If Target.Address = "$F$5" Then
Call myMacro
End If

ws_exit:
Application.EnableEvents = True
End Sub

'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.


--

HTH

RP
(remove nothere from the email address if mailing direct)


"LDanix" wrote in message
...
Where do I enter all this?

"Lonnie M." wrote:

Hi, you could use procedures like this. It will pass the cell

address,
which you could then test and run macros accordingly.

Worksheet_SelectionChange(ByVal Target As Excel.Range, Cancel As
Boolean)
Worksheet_BeforeDoubleClick(ByVal Target As Excel.Range, Cancel As
Boolean)

HTH--Lonnie M.







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
Macro - Fixed text code needs replacing with variable text steven.holloway Excel Discussion (Misc queries) 3 July 22nd 08 03:57 PM
Macro - Inserting text to a cell already containg text Dileep Chandran Excel Worksheet Functions 5 December 7th 06 03:42 PM
Macro - Inserting text to a cell already containg text Dileep Chandran Excel Discussion (Misc queries) 6 December 7th 06 03:42 PM
Need a macro to insert text in a cell that already has text.Excel go1angel Excel Discussion (Misc queries) 2 October 5th 05 10:32 PM
Macro or Function to make text size to suite text Length? lbbss Excel Discussion (Misc queries) 4 December 14th 04 07:53 PM


All times are GMT +1. The time now is 01:08 AM.

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

About Us

"It's about Microsoft Excel"