mercredi 26 mai 2021

How can I get this VBA IF THEN Statement to work

I have a multi-select ListBox for selecting "colours" and have copied the code into a second module and renaming where required, in order to create a second ListBox for "tags". There is also code in Worksheet SelectionChange that I am trying to amend in order to get both of them working.

Everything I have tried alternates with "block if without end if" errors, to one of them working, to none. How can I fix this code?

Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)
    If Target.Cells.Count > 1 Then Exit Sub
    If Not Intersect(Target, ColourArea(ActiveSheet)) Is Nothing Then
        If Target.Column = 7 And Target.OFFSET(0, -5).Value = "variable"
            CreateTagPopUp Target
        End If
        If Not Intersect(Target, TagArea(ActiveSheet)) Is Nothing Then
            If Target.Column = 8 And Target.OFFSET(0, -6).Value = "variable" Then 
                CreateColourPopUp Target
            End If
        Else
            DeleteAllTagPopUps Target
            DeleteAllColourPopUps Target
        End If
    End If
End Sub

Aucun commentaire:

Enregistrer un commentaire