Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Target.Address & Target.Address.Row

I'm trying to use Target.Address and target.Address.row however I keep get Invlaid qualifier. I would be grateful if anyone can offer some help please.

Code:

    Private Sub Worksheet_Change(ByVal Target As Range)

    Application.EnableEvents = False

    On Error GoTo Error1

    If Target.Column = 10 Then

        If Target.Address.Value = "Y" Then

            Target.Address.Row.Interior.Pattern.Color = 255

        End If

    End If

    Y
Letscontinue:
    Application.EnableEvents = True
    Exit Sub

Error1:
    MsgBox Err.Description
    Resume Letscontinue:


End Sub
like image 368
user1624926 Avatar asked Sep 13 '25 09:09

user1624926


1 Answers

I think one of these is what you are trying?

Private Sub Worksheet_Change(ByVal Target As Range)
    Dim sPass As String

    '~~. This is to prevent the code from crashing when a paste happens in more
    '~~> than 1 cell. Also in Pre Excel versions, replace .CountLarge with .Count
    If Target.Cells.CountLarge > 1 Then Exit Sub

    sPass = "PASSWORD" '<~~ Your password

    Application.EnableEvents = False

    On Error GoTo Error1

    If Not Intersect(Target, Columns(10)) Is Nothing And _
    UCase(Trim(Target.Value)) = "Y" Then
        ActiveSheet.Unprotect sPass

        Target.EntireRow.Interior.Color = 255
        Target.EntireRow.Locked = True

        ActiveSheet.Protect sPass
    End If

Letscontinue:
    Application.EnableEvents = True
    Exit Sub
Error1:
    MsgBox Err.Description
    Resume Letscontinue
End Sub
like image 77
Siddharth Rout Avatar answered Sep 15 '25 23:09

Siddharth Rout