Sheet Cleanup Help Please
Hello again, try the below.
Sub Macro()
Dim lngLastCol1 As Long, lngLastCol2 As Long
lngLastCol1 = Cells(1, Columns.Count).End(xlToLeft).Column
lngLastCol2 = ActiveSheet.Cells.Find(What:="*", _
SearchDirection:=xlPrevious, SearchOrder:=xlByColumns).Column
If lngLastCol2 lngLastCol1 Then
Columns(lngLastCol1 + 1).Resize(, _
lngLastCol2 - lngLastCol1).ClearContents
End If
End Sub
--
Jacob (MVP - Excel)
"BlueAngel" wrote:
I have a sheet that has formatting pre set for Columns A:BM. My data key
will be row 1. I need to clear all data in all rows to the right of where
row 1 data ends.
Example:
Col A Col B Col c Col D Col E
Row
1 Data Data Data
Data population ends in Cell C1, Clear all data D:BM.
Col A Col B Col c Col D Col E
Row
1 Data Data Data Data
Data population end in Cell D1, Clear all data E:BM
Can someone help with VBA that will automatically clear this?
Thanks in advance,
|