I am trying to clear contents of an active row and shifting the bottom rows up. I want to clear instead of delete because I have data validation and formulas in my cells. I keep getting an error when using the following VBA, i understand that shift:=xlUp will only work with a .delete command. Is there any way to have this work with .clearcontents?
Sub shiftmeup()
Dim ws As Worksheet
Dim wb As Workbook
Set wb = ThisWorkbook
Set ws = wb.Sheets("Contacts") '/// The underhood of my contacts
With ws.Range("D11:BL392")
For i = .Rows.Count To 1 Step -1
If IsEmpty(.Cells(i, 1)) Then .Rows(i).ClearContents shift:=xlUp
Next
End With
End Sub
You cannot "shift the bottom rows up" without deleting. ClearContents
literally just does that, clears the cell's .value
and then doesn't modify the xlsx
beyond that.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.