ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Run a macro when a cell changes (https://www.excelbanter.com/excel-discussion-misc-queries/68071-run-macro-when-cell-changes.html)

mjb2005

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


Anne Troy

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




mjb2005

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



Bob Phillips

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




mjb2005

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


Bob Phillips

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





All times are GMT +1. The time now is 03:59 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com