Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 162
Default Run Macro after cell content changes...

Hello fellow programmers! I am in need of a macro that will simply jump
to another location on a spreadsheet after the end-user types anything
in a particular cell... I would like it so that if someone types an
answer for a question in cell A2 a macro will fire causing the
spreadsheet to then select cell A6. Thanks!

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Run Macro after cell content changes...

Private Sub Worksheet_Change(ByVal Target As Range)
Const WS_RANGE As String = "A2"

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
With Target
Me.Range("A6").Select
End With
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

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

wrote in message
ups.com...
Hello fellow programmers! I am in need of a macro that will simply jump
to another location on a spreadsheet after the end-user types anything
in a particular cell... I would like it so that if someone types an
answer for a question in cell A2 a macro will fire causing the
spreadsheet to then select cell A6. Thanks!



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 170
Default Run Macro after cell content changes...

My thanks to both of you, for asking the question and for the answer. I have
been agonizing over a scenario like this for days!

I need to continue this process of moving to a new cell after input through
about 60 additional cells. Do I need to repeat the sequence with new sub
routines, target names, and so forth for each cell I want to move to/from.

"Bob Phillips" wrote:

Private Sub Worksheet_Change(ByVal Target As Range)
Const WS_RANGE As String = "A2"

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
With Target
Me.Range("A6").Select
End With
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

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

wrote in message
ups.com...
Hello fellow programmers! I am in need of a macro that will simply jump
to another location on a spreadsheet after the end-user types anything
in a particular cell... I would like it so that if someone types an
answer for a question in cell A2 a macro will fire causing the
spreadsheet to then select cell A6. Thanks!




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Run Macro after cell content changes...

Absolutely not, there is only one Change event per sheet.

Minimum is to change the constant WS_RANGE to your target range of cells

If it is a fixed movement, say 1 cell right, 2 cells down, it is simple,
just change

Me.Range("A6").Select

to
.Offset(2,1).select

If it is more complex, taht is thereis not pattern, use something like

Select Case .Address(0,0)
Case "A2": Me.Range("A6").elect
Case "B1": Me.Range("H17").Select
'etc
End Select

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"JR Hester" wrote in message
...
My thanks to both of you, for asking the question and for the answer. I

have
been agonizing over a scenario like this for days!

I need to continue this process of moving to a new cell after input

through
about 60 additional cells. Do I need to repeat the sequence with new sub
routines, target names, and so forth for each cell I want to move to/from.

"Bob Phillips" wrote:

Private Sub Worksheet_Change(ByVal Target As Range)
Const WS_RANGE As String = "A2"

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
With Target
Me.Range("A6").Select
End With
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

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

wrote in message
ups.com...
Hello fellow programmers! I am in need of a macro that will simply

jump
to another location on a spreadsheet after the end-user types anything
in a particular cell... I would like it so that if someone types an
answer for a question in cell A2 a macro will fire causing the
spreadsheet to then select cell A6. Thanks!






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
Using macro to copy a part of a cell content to next cell Charles Excel Discussion (Misc queries) 6 May 31st 06 05:57 AM
How to check a cell for content before running macro. Incoherent Excel Programming 1 October 7th 05 04:42 PM
Macro on cell content Riko Wichmann New Users to Excel 2 March 3rd 05 02:07 PM
A Macro to Edit Cell Content jer101 Excel Programming 2 June 17th 04 10:42 PM
macro clearing cell content Tyler[_2_] Excel Programming 2 November 19th 03 05:51 AM


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