detriez
Board Regular
- Joined
- Sep 13, 2011
- Messages
- 193
- Office Version
- 365
- Platform
- Windows
I'm trying to get this to clear the contents of everything except Row 1 when it is populated
This works when only run once. But, running it a second time will clear the contents of row 1 as well
I tried adding a +1 to the LastRow line but that didn't matter
This works when only run once. But, running it a second time will clear the contents of row 1 as well
I tried adding a +1 to the LastRow line but that didn't matter
VBA Code:
Dim thiswksht As Worksheet
Dim LastRow As Long
Dim LastCol As Integer
Dim rngRange As Range
Set thiswksht = ActiveSheet
With thiswksht
LastRow = Cells(Cells.Rows.Count, "B").End(xlUp).Row
LastCol = Cells(1, Columns.Count).End(xlToLeft).Column
End With
Set rngRange = Range("A2", Cells(LastRow, LastCol))
rngRange.name = "tbl_P"
With rngRange
End With
Selection.ClearContents
Range("A2:BI2").Select
With Selection.Interior
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorAccent6
.TintAndShade = 0.399975585192419
.PatternTintAndShade = 0
End With