Vincent88
Active Member
- Joined
- Mar 5, 2021
- Messages
- 382
- Office Version
- 2019
- Platform
- Windows
- Mobile
Hi Guys,
How to change my code to enable or disable the formatting cell ( to make it patterned if it isn't or return to non-patterned if it is patterned).
How to change my code to enable or disable the formatting cell ( to make it patterned if it isn't or return to non-patterned if it is patterned).
VBA Code:
Private Sub Workbook_SheetBeforeDoubleClick(ByVal Sh As Object, ByVal Target As Range, Cancel As Boolean)
If Sh.Name = "Data" Then Exit Sub
Dim lr As Long
Dim Lc As Long
lr = Range("A" & Rows.Count).End(xlUp).Row
Lc = Cells(1, Columns.Count).End(xlToLeft).Column
Dim rngArea As Range
Set rngArea = Range(Cells(3, 8), Cells(lr, Lc))
Debug.Print rngArea.Address
If Not Intersect(Target, rngArea) Is Nothing Then
Cancel = True
If Not IsEmpty(Target.Value) Then Exit Sub
With Target.Interior
.Pattern = xlPatternUp
.PatternColor = RGB(166, 166, 166)
End With
End If
End Sub