muhammad susanto
Well-known Member
- Joined
- Jan 8, 2013
- Messages
- 2,077
- Office Version
- 365
- 2021
- Platform
- Windows
hi all..
this code not fully working, how t o fix it to delete content with data up if there is blank row (above), and in col "name" automatic delete if data move up
this code:
this my table (before run macro):
expected result (after run macro)
thank in advance
susanto
this code not fully working, how t o fix it to delete content with data up if there is blank row (above), and in col "name" automatic delete if data move up
this code:
VBA Code:
Sub clearcontent()
Dim lngLastRow As Long
Dim wsSrc As Worksheet
With Application
.ScreenUpdating = False
.EnableEvents = False
.Calculation = xlCalculationManual
End With
Set wsSrc = ActiveSheet
lngLastRow = wsSrc.Range("C:E").Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
Dim RowsToDelete As Range
' Only delete the table area (If you know you have nothing to the right you could dispense
' with the intersect and just delete the entirerow)
Set RowsToDelete = Intersect(wsSrc.Range("C2:E" & lngLastRow), _
wsSrc.Range("C2:A" & lngLastRow).SpecialCells(xlCellTypeBlanks).EntireRow)
RowsToDelete.Delete Shift:=xlUp
With Application
.ScreenUpdating = True
.EnableEvents = True
.Calculation = xlCalculationAutomatic
.CalculateFull
End With
End Sub
Book1 | |||||||||
---|---|---|---|---|---|---|---|---|---|
A | B | C | D | E | F | G | |||
1 | Ref | REF Verif | name | NOMOR REGISTER LELANG | REGISTER LELANG | Tahun Lelang | Bulan Lelang | ||
2 | 1 | A | John | 1 | ok | 2020 | 7 | ||
3 | 2 | A | John | 34 | good | 2020 | 7 | ||
4 | 3 | A | John | 2020 | 7 | ||||
5 | 4 | A1 | John | excelent | 2020 | 7 | |||
6 | 5 | A2 | John | 2020 | 7 | ||||
7 | 6 | A3 | John | 5 | poor | 2020 | 5 | ||
8 | 7 | A4 | John | 4 | bad | 2020 | 5 | ||
Sheet1 |
expected result (after run macro)
Book1 | |||||||||
---|---|---|---|---|---|---|---|---|---|
A | B | C | D | E | F | G | |||
11 | Ref | REF Verif | name | NOMOR REGISTER LELANG | REGISTER LELANG | Tahun Lelang | Bulan Lelang | ||
12 | 1 | A | John | 1 | ok | 2020 | 7 | ||
13 | 2 | A | John | 34 | good | 2020 | 7 | ||
14 | 3 | A | John | excelent | 2020 | 7 | |||
15 | 4 | A1 | John | 5 | poor | 2020 | 7 | ||
16 | 5 | A2 | John | 4 | bad | 2020 | 7 | ||
17 | 6 | A3 | 2020 | 5 | |||||
18 | 7 | A4 | 2020 | 5 | |||||
Sheet1 |
thank in advance
susanto