Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default active cell to run macro

Hello,

it is possibel that when in sheet1 a1 cell is active to run macro
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 538
Default active cell to run macro

kalpesh wrote:

it is possibel that when in sheet1 a1 cell is active to run macro


One way is the Worksheet_SelectionChange event. Place this in the worksheet's
class:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If "$A$1" = ActiveCell.Address Then
'your code here
End If
End Sub

If you want your code to run when A1 is the only thing selected, change
ActiveCell.Address to Target.Address.

--
I can't believe he would even THINK of something like... like...
Oh, who the hell am I kidding? Yes I can.
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 621
Default active cell to run macro

Auric has pointed you to a method use a selection chamge event.

There are other event types you could use if you choose

BeforeRightClick

BeforeDoubleClick

Sample code..............................

Private Sub Worksheet_BeforeDoubleClick( _
ByVal Target As Excel.Range, Cancel As Boolean)
Select Case Target.Address(False, False)
Case "A1"
Cancel = True
MyA1Macro
Case "B1"
Cancel = True
MyB1Macro
Case "C1"
Cancel = True
MyC15Macro
End Select
End Sub


Gord

On Mon, 06 Feb 2012 11:19:23 -0600, kalpesh
wrote:

Hello,

it is possibel that when in sheet1 a1 cell is active to run macro

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 621
Default active cell to run macro

Please make correction to MyC15Macro

Should read MyC1Macro


Gord

On Mon, 06 Feb 2012 12:11:14 -0800, Gord Dibben
wrote:

Auric has pointed you to a method use a selection chamge event.

There are other event types you could use if you choose

BeforeRightClick

BeforeDoubleClick

Sample code..............................

Private Sub Worksheet_BeforeDoubleClick( _
ByVal Target As Excel.Range, Cancel As Boolean)
Select Case Target.Address(False, False)
Case "A1"
Cancel = True
MyA1Macro
Case "B1"
Cancel = True
MyB1Macro
Case "C1"
Cancel = True
MyC15Macro
End Select
End Sub


Gord

On Mon, 06 Feb 2012 11:19:23 -0600, kalpesh
wrote:

Hello,

it is possibel that when in sheet1 a1 cell is active to run macro

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-active cell puiuluipui Excel Discussion (Misc queries) 3 March 14th 10 04:21 PM
run macro although blinking cursor is active in an active cell bartman1980 Excel Programming 1 December 20th 07 11:29 AM
Macro to paste in the active cell the contents of a cell from another file?? LarryB Excel Programming 3 June 12th 06 06:37 PM
Run macro in active cell ku Excel Programming 4 August 6th 04 06:36 PM
Run a macro in the active cell. Jasmine[_2_] Excel Programming 1 January 5th 04 03:47 PM


All times are GMT +1. The time now is 08:54 PM.

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"