help with vba

p4nny

Board Regular
Joined
Jan 13, 2015
Messages
246
Hi

The problem here is I'm trying to run 2 separate pieces of code independently within the same sub. The first part of the code changes the row colour when range AA = "closed"

The second part enters a message in column D when C = "Y" or "N"


Any help is appreciated.

Code:
Private Sub Worksheet_Change(ByVal Target As Range)


On Error Resume Next


Dim i As Long, r1 As Range, r2 As Range


   For i = 2 To 1000
      Set r1 = Range("aa" & i)
      Set r2 = Range("A" & i & ":ab" & i)
      If r1 = "closed" Then r2.Interior.ColorIndex = 15




      
      Exit Sub
      
      
   Next i




    
    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
 
Hi,

I think you're assuming that I have a level of knowledge about your workbook. Could you describe exactly what you're trying to do? Is this something related to changing a value in Column C since that's what the original code was intended to do.

WBD
 
Upvote 0

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
Hi

thanks for your reply.

When testRange = Y, I would like to find the value located in offset(,-1) in the sheet called Dependencies.

Hope that makes sense

I think I'm struggling with writing the Find function in the correct format. I've googled it too.

Many thanks
 
Upvote 0

Forum statistics

Threads
1,214,402
Messages
6,119,299
Members
448,885
Latest member
LokiSonic

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