Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
mjb2005
 
Posts: n/a
Default Run a macro when a cell changes

Hello
I'm just having a really bad day I guess. I was wondering if some kind
soul could help.
I have created 12 macros called pastejanuary, pastefebruary, pastemarch
etc etc etc. These are pastespecial operations.
What I would like to do is if the cell $g$1 changes from january to
february, run the macro called pastefebruary.
Any ideas would be greatly appreciated. I created private sub
worksheet_change(by val target as excel range and then asked for the
range $g$1 and range value of February but thats where I ran into
trouble.
I cannot for the life of me get it to run the pastefebruary macro.

I really would appreciate any help you could give me
Cheers

  #2   Report Post  
Posted to microsoft.public.excel.misc
Anne Troy
 
Posts: n/a
Default Run a macro when a cell changes

Try this: http://support.microsoft.com/?kbid=142154
************
Hope it helps!
Anne Troy
www.OfficeArticles.com

"mjb2005" wrote in message
oups.com...
Hello
I'm just having a really bad day I guess. I was wondering if some kind
soul could help.
I have created 12 macros called pastejanuary, pastefebruary, pastemarch
etc etc etc. These are pastespecial operations.
What I would like to do is if the cell $g$1 changes from january to
february, run the macro called pastefebruary.
Any ideas would be greatly appreciated. I created private sub
worksheet_change(by val target as excel range and then asked for the
range $g$1 and range value of February but thats where I ran into
trouble.
I cannot for the life of me get it to run the pastefebruary macro.

I really would appreciate any help you could give me
Cheers



  #3   Report Post  
Posted to microsoft.public.excel.misc
mjb2005
 
Posts: n/a
Default Run a macro when a cell changes

Thanks Anne
I did try this earlier on but I probably should have been a bit clearer
for everyone in that I don't really want to run just one macro because
(maybe a bit stupidly) I have created 12 different macros for each
month and when the month changes say to March, I only want to run the
March Macro.
Clear as mud?
Thanks again
Anne Troy wrote:

Try this: http://support.microsoft.com/?kbid=142154
************
Hope it helps!
Anne Troy
www.OfficeArticles.com

"mjb2005" wrote in message
oups.com...
Hello
I'm just having a really bad day I guess. I was wondering if some kind
soul could help.
I have created 12 macros called pastejanuary, pastefebruary, pastemarch
etc etc etc. These are pastespecial operations.
What I would like to do is if the cell $g$1 changes from january to
february, run the macro called pastefebruary.
Any ideas would be greatly appreciated. I created private sub
worksheet_change(by val target as excel range and then asked for the
range $g$1 and range value of February but thats where I ran into
trouble.
I cannot for the life of me get it to run the pastefebruary macro.

I really would appreciate any help you could give me
Cheers


  #4   Report Post  
Posted to microsoft.public.excel.misc
Bob Phillips
 
Posts: n/a
Default Run a macro when a cell changes

Private Sub Worksheet_Change(ByVal Target As Range)

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range("G1")) Is Nothing Then
With Target
Select Case LCase(.Value)
Case "january": PasteJanuary
Case "february": PasteFebruary
'etc.
End 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

(remove nothere from the email address if mailing direct)

"mjb2005" wrote in message
oups.com...
Hello
I'm just having a really bad day I guess. I was wondering if some kind
soul could help.
I have created 12 macros called pastejanuary, pastefebruary, pastemarch
etc etc etc. These are pastespecial operations.
What I would like to do is if the cell $g$1 changes from january to
february, run the macro called pastefebruary.
Any ideas would be greatly appreciated. I created private sub
worksheet_change(by val target as excel range and then asked for the
range $g$1 and range value of February but thats where I ran into
trouble.
I cannot for the life of me get it to run the pastefebruary macro.

I really would appreciate any help you could give me
Cheers



  #5   Report Post  
Posted to microsoft.public.excel.misc
mjb2005
 
Posts: n/a
Default Run a macro when a cell changes

Dear Bob
I must thank you so much. I am new to vb and even though I was sort of
on the right track, I just couldn't get the old grey matter around it.
I really appreciate your help
Thank you again
Marlene



  #6   Report Post  
Posted to microsoft.public.excel.misc
Bob Phillips
 
Posts: n/a
Default Run a macro when a cell changes

It's a pleasure Marlene.

Bob

"mjb2005" wrote in message
ups.com...
Dear Bob
I must thank you so much. I am new to vb and even though I was sort of
on the right track, I just couldn't get the old grey matter around it.
I really appreciate your help
Thank you again
Marlene



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
run a macro in a locked cell Ray Excel Discussion (Misc queries) 8 January 10th 06 12:02 AM
Can a macro be made to run on entering or leaving a cell? Dave Lister Excel Discussion (Misc queries) 1 December 3rd 05 07:11 PM
Macro code for dropping to next empty cell JB2010 Excel Discussion (Misc queries) 4 November 3rd 05 01:35 PM
Keyboard Macro Just Copies Content of Previous Cell Andy Excel Discussion (Misc queries) 1 October 24th 05 11:54 PM
Copy cell format to cell on another worksht and update automatical kevinm Excel Worksheet Functions 21 May 19th 05 11:07 AM


All times are GMT +1. The time now is 04:25 PM.

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

About Us

"It's about Microsoft Excel"