Dabbling in Worksheet Events - But Not getting the result I want

TheRedCardinal

Board Regular
Joined
Jul 11, 2019
Messages
243
Office Version
  1. 365
  2. 2021
Platform
  1. Windows
So here's what I want to happen:

  1. If the user makes a change in column "Q" of the worksheet, activate some code
  2. If the user enters the words "Checked and OK" then further action needed, if not, then we can exit the checks
  3. If the text is entered, then find the value in Column B of the same row as was changed
  4. Find that value in Column A of another worksheet
  5. Enter 2 values in Columns G and H of that second worksheet
  6. Enter a value in the cell next to the changed one
I composed this:

VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Column = 17 Then

    If InStr(1, Target.Offset(0, -14).Value, "Checked and OK") > 0 Then

        CellB = ThisWorkbook.Sheets("Invoice Checks").Range("A:A").Find(Target.Value)
        
        If Not CellB Is Nothing Then
        
            CellB.Offset(0, 6) = Target.Value
            CellB.Offset(0, 7) = "Yes"
            Target.Offset(0, 1) = "Yes"
        
        End If
    
    End If

End If

End Sub

As per the title, it isn't working for me.

So I added this line:

VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)

Target.Offset(0, 1) = "Activated"

Thinking that whatever happened, if I changed a cell on the sheet where this code exists, the next column over would show "Activated" but sadly not.

What have I missed?
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
Try something like this:

VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)

If Not Intersect(Target, Range("Q:Q")) Is Nothing Then

    If InStr(1, Target.Offset(0, -14).Value, "Checked and OK") > 0 Then

        CellB = ThisWorkbook.Sheets("Invoice Checks").Range("A:A").Find(Target.Value)
        
        If Not CellB Is Nothing Then
        
            CellB.Offset(0, 6) = Target.Value
            CellB.Offset(0, 7) = "Yes"
            Target.Offset(0, 1) = "Yes"
        
        End If
    
    End If

End If

End Sub
 
Upvote 0
How strange - it was the disabled events issue, even though I turned them on.

Must have been switched off somewhere in my code. I'll look for it.
 
Upvote 0
Solution

Forum statistics

Threads
1,214,950
Messages
6,122,436
Members
449,083
Latest member
Ava19

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