Hi everyone
I need a help ..
In my worksheet "EDIT" if I enter any value in A1, I want a macro (mymacro) to run automatically
Can someone help in coding..
Thanks
Tom
Hi everyone
I need a help ..
In my worksheet "EDIT" if I enter any value in A1, I want a macro (mymacro) to run automatically
Can someone help in coding..
Thanks
Tom
Last edited by SMILE; 09-08-2011 at 02:11 AM.
Hi SMILE, tryEDIT: Sorry for skipping this part but the previous code needs to go into your worksheet module in the VBE.![]()
Private Sub Worksheet_Change(ByVal Target As Range) If Target.Address = "$A$1" Then '''Your code here''' End If End Sub
Last edited by Mordred; 09-07-2011 at 03:54 PM.
If you're happy with someone's help, click that little star at the bottom left of their post to give them Reps.
---Keep on Coding in the Free World---
Hi..Mordred
Thanks for the reply but I am getting the following error
compile error:
Ambiguous name detected:Worksheet_Change
Is it because I have another codes in that worksheet as below
Hope you will sort it out for me.![]()
Private Sub Worksheet_Change(ByVal Target As Range) Const sTRIGGER_CELL = "e11" If Not Intersect(Target, Range(sTRIGGER_CELL)) Is Nothing Then Select Case UCase(Range(sTRIGGER_CELL).Value) Case "Y" yes Case "N" no End Select End If End Sub
Thanks
Tom
Yes, it is because of that code. You can get around this by either:
1. erase the other code
2. add the if statement from my solution to your existing codeor you can use the double click event![]()
Private Sub Worksheet_Change(ByVal Target As Range) Const sTRIGGER_CELL = "e11" If Target.Address = "$A$1" Then '''Your code here''' End If If Not Intersect(Target, Range(sTRIGGER_CELL)) Is Nothing Then Select Case UCase(Range(sTRIGGER_CELL).Value) Case "Y" yes Case "N" no End Select End If End Sub
![]()
Private Sub Worksheet_BeforeDoubleClick(ByVal _ Target As Range, Cancel As Boolean) If Target.Address = "$A$1" Then '''Your code here''' End If End Sub
Hi Mordred
I am really sorry to bother you again...
Your code is working perfect..but I need to add one more condition
My existing code is as below
I need the following condtion also to be added![]()
Private Sub Worksheet_Change(ByVal Target As Range) Const sTRIGGER_CELL = "e11" If Target.Address = "$a$1" Then '''Your code here''' Range("B13:e18").Select Selection.clearcontents Range("e11").Select End If If Not Intersect(Target, Range(sTRIGGER_CELL)) Is Nothing Then Select Case UCase(Range(sTRIGGER_CELL).Value) Case "Y" yes Case "N" no End Select End If End Sub
IF I go to A1 and press back space (no value) and enter, then I just need the following cell to select.
If any other value enter in A1, then I need the following as my previous code![]()
Range("e11").Select
Thanks![]()
Range("B13:e18").Select Selection.clearcontents Range("e11").Select
tom
just add code to test value of a1
if range("a1").value = "" then exit sub
Please Read Forum Rules Before Posting
Wrap VBA code by selecting the code and clicking the # icon or Read This
How To Cross Post politely
Top Excel links for beginners to Experts
If you are pleased with a member's answer then use the Scales icon to rate it
If my reply has assistedor failed to assist you
I welcome your Feedback.
Hi Tom, try the following outNote: I commented out the existing code because I couldn't run it and am honestly confused as to how the variables yes and no are defined or known! At any rate, see if the code works the way it is and then remove the single quotes for the other code.![]()
Private Sub Worksheet_Change(ByVal Target As Range) Const sTRIGGER_CELL = "e11" If Target.Address = "$A$1" And Target.Value <> "" Then '''Your code here''' Application.EnableEvents = False Range("B13:e18").ClearContents Range("E11").Select Application.EnableEvents = True ElseIf Target.Address = "$A$1" And Target.Value = "" Then Application.EnableEvents = False Range("E11").Select Application.EnableEvents = True End If 'If Not Intersect(Target, Range(sTRIGGER_CELL)) Is Nothing Then ' Select Case UCase(Range(sTRIGGER_CELL).Value) ' Case "Y" ' yes <<---| ' Case "N" |-------What defines these? ' no <<---| ' End Select 'End If End Sub
Regards:
Thank u Mordred.. Its working perfect...
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks