VBA Code Alteration

wlbamc

Board Regular
Joined
Apr 19, 2016
Messages
99
Office Version
  1. 2016
I have the following code which turns the cells red if they are not completed when you choose from the dropdown in Column Z. I want to change this to dropdown in column P. Any help please

VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    Application.ScreenUpdating = False
    If Intersect(Target, Range("A:Z")) Is Nothing Then Exit Sub
    On Error GoTo endit
    Application.EnableEvents = False
    Select Case Target.Column
        Case Is = 26
            If WorksheetFunction.CountA(Range("A" & Target.Row).Resize(, 25)) < 25 Then
                Range("A" & Target.Row).Resize(, 25).SpecialCells(xlCellTypeBlanks).Interior.ColorIndex = 3
                MsgBox ("Please enter data in the red cells.")
                Application.EnableEvents = True
                Exit Sub
            End If
            If Target.Value = "No LTC input" Then
                Target.EntireRow.Copy Worksheets("Inactive").Cells(Rows.Count, 1).End(xlUp).Offset(1, 0)
                Target.EntireRow.Delete
            ElseIf Target.Value = "Deceased" Then
                Target.EntireRow.Copy Worksheets("Inactive").Cells(Rows.Count, 1).End(xlUp).Offset(1, 0)
                Target.EntireRow.Delete
            ElseIf Target.Value = "D2A (Own Home)" Then
                Target.EntireRow.Copy Worksheets("D2A").Cells(Rows.Count, 1).End(xlUp).Offset(1, 0)
                Target.EntireRow.Delete
            ElseIf Target.Value = "D2A (Care Home)" Then
                Target.EntireRow.Copy Worksheets("D2A").Cells(Rows.Count, 1).End(xlUp).Offset(1, 0)
                Target.EntireRow.Delete
            ElseIf Target.Value = "LTC Team withdrew prior to Discharge" Then
                Target.EntireRow.Copy Worksheets("Inactive").Cells(Rows.Count, 1).End(xlUp).Offset(1, 0)
                Target.EntireRow.Delete
            ElseIf Target.Value = "Discharged to Own Home" Then
                Target.EntireRow.Copy Worksheets("Inactive").Cells(Rows.Count, 1).End(xlUp).Offset(1, 0)
                Target.EntireRow.Delete
            ElseIf Target.Value = "Discharged to Care Home" Then
                Target.EntireRow.Copy Worksheets("Inactive").Cells(Rows.Count, 1).End(xlUp).Offset(1, 0)
                Target.EntireRow.Delete
            End If
        Case Is <= 19
            If Target <> "" Then
                Target.Interior.ColorIndex = xlNone
            End If
    End Select
endit:
     Application.EnableEvents = True
     Application.ScreenUpdating = True
End Sub
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
Thank you, I have got the red boxes to stop at P by also changing the 25's to 15 but it is now not moving to the completed tab, any ideas please
 
Upvote 0
I think you will need to either change or elimiate this part:
VBA Code:
        Case Is <= 19
            If Target <> "" Then
                Target.Interior.ColorIndex = xlNone
            End If
As 16 is less than 19, so changes to coluimn P would cause that part to run too!
 
Upvote 0

Forum statistics

Threads
1,223,907
Messages
6,175,301
Members
452,633
Latest member
DougMo

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