vba help

p4nny

Board Regular
Joined
Jan 13, 2015
Messages
246
Hello

Hopefully very easy to fix.. I would like this applicable to all cells with C2:C10000 and D2:1000

So if in cell C3 I change the cell to Y, D3 would update..

Works fine at the moment but on a cell C2.

Many thanks



Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)   
        If Sheets("Action Plan").Range("c2") = "Y" Then


Sheets("Action Plan").Range("D2") = "Key in the dependency ID"
Else
Sheets("Action Plan").Range("d2") = "N/A"
End If
End Sub
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
Try this.
Code:
Private Sub Worksheet_Change(ByVal Target As Range)   

    If Intersect(Target,Range("C2:C100000)) Is Nothing Then
        Exit Sub
    End If

    Application.EnableEvents = False

    If Target.Value = "Y" Then
        Target.Offset(,1).Value = "Key in the dependency ID"
    Else
        Target.Offset(,1).Value = "N/A"
    End If

    Application.EnableEvents = True

End Sub
 
Upvote 0
Try this.

I just want to paste this code with just two small exception. In my version the C100000 would be C10000 :P and did not use the enableevents function.
@Norie: is the enableevents really necessary? What this do here?
 
Upvote 0
Since the code in the Change event could change the sheet it could end up triggering itself so, though not entirely necessary, disabling events is probably a good idea.
 
Upvote 0
Thanks guys - code works fine. One question, if I insert a new row into the sheet, I get a "mis-match" error and the code seems to stop working. Is there "wrap around" I can do.. On error.. Resume Next

thanks again
 
Upvote 0
You can test how many cells Target consists of, if it's more than one exit.
Code:
If Target.Cells.Count > 1 Exit Sub
 
Upvote 0

Forum statistics

Threads
1,224,824
Messages
6,181,187
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top