3 different IF statements to detect cell values in Worksheet_Change

rtaylor1987

New Member
Joined
Nov 30, 2021
Messages
6
I'm working on a project where I need to be able to read data from different cells and sort these into different sheets depending on value.
Essentially, when you load data - it should be able to read the following:
Cases that are listed as active (If value = "active" then move to sheet Active)
cases that are pending (If Start Date is less than 30 days, it's flagged with a "y" in the system, so if Value="y" then move to "Pending"
cases that are already closed (If "closed date" is NOT null) then move them to the "closed" sheet

I have the Active part working, so I thought the code was fairly straight forward but it doesn't appear to like me pushing IF statements back-to-back. (I'm still fairly new to VB so it's most likely user error)

Any way to get each of these separate functions executed when worksheet change is detected?

VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
      If Target.Column = 28 And Target.Cells.Count = 1 Then
        If LCase(Target.Value) = "active" Then
            With Target.EntireRow
                .Copy Sheets("Active").Range("A" & Rows.Count).End(xlUp).Offset(1, 0)
                .Delete
            End With
        End If
  End If
  If Target.Column = 18 And Target.Cells.Count = 1 Then
        If LCase(Target.Value) = "y" Then
            With Target.EntireRow
                .Copy Sheets("Pending").Range("A" & Rows.Count).End(xlUp).Offset(1, 0)
                .Delete
            End With
        End If
  End If
  If Target.Column = 12 And Target.Cells.Count = 1 Then
        If Not LCase(Target.Value) = "null" Then
            With Target.EntireRow
                .Copy Sheets("Closed").Range("A" & Rows.Count).End(xlUp).Offset(1, 0)
                .Delete
            End With
        End If
  End If
End Sub
 
I'm beyond totally stumped.

I'm trying to navigate some different avenues to make this fairly more automated, because I feel like this isn't going to achieve what I need from the project. Thanks for your help!
 
Upvote 0

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.

Forum statistics

Threads
1,223,903
Messages
6,175,284
Members
452,630
Latest member
OdubiYouth

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