delete last cell data of all rows in last 3 tables

there are 4 tables
what I want is delete the last cell data of all rows  in last 3 tables
cells highlighted in yellow colour are the last cell data of last 3 tables
this highlighted colour is only for understanding purpose in actual file there is no highlighted colour
see the sample file
Book20.xlsm
Avinash SinghAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

aikimarkCommented:
Sub Q_29098231()
    Dim wks As Worksheet
    Dim rng As Range
    Dim lngLoop As Long
    Dim lngRow As Long

    Set wks = Worksheets("sheet1")
    Set rng = wks.Cells(wks.Rows.Count, 1).End(xlUp)
    lngRow = rng.Row
    For lngLoop = 1 To 3
        wks.Rows(rng.Row).Delete
        Set rng = wks.Cells(lngRow, 1).End(xlUp)
        Set rng = rng.End(xlUp)
        Set rng = rng.End(xlUp)
        lngRow = rng.Row
    Next
End Sub

Open in new window

0
Avinash SinghAuthor Commented:
I want to delete the last cell of all rows with data in table 2,table3,table4
Kindly check the sample file i have highlighted what i want
0
aikimarkCommented:
Ah.  I mistook last cell to be the last row.
0
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

Subodh Tiwari (Neeraj)Excel & VBA ExpertCommented:
You may try something like this...
Sub DeleteLastCellInLastThreeTables()
Dim lr As Long
Dim Rng As Range, Cell As Range

lr = Cells(Rows.Count, 1).End(xlUp).Row

For Each Rng In Range(Range("A1").End(xlDown).Offset(1), Range("A" & lr)).SpecialCells(xlCellTypeConstants, 3).Areas
    For Each Cell In Rng.Cells(1).Offset(1).Resize(Rng.Cells.Count - 1).Cells
        Cell.End(xlToRight).Clear
    Next Cell
Next Rng

End Sub

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
aikimarkCommented:
Sub Q_29098231()
    Dim wks As Worksheet
    Dim rng As Range
    Dim lngLoop As Long
    Dim lngTopRow As Long
    Dim lngRow As Long
    
    Set wks = Worksheets("sheet1")
    Set rng = wks.Cells(wks.Rows.Count, 1).End(xlUp)
    lngTopRow = rng.End(xlUp).Row
    
    Application.ScreenUpdating = False
    For lngLoop = 1 To 3
        For lngRow = rng.Row To lngTopRow + 1 Step -1
            wks.Cells(lngRow, wks.Columns.Count).End(xlToLeft).ClearContents
        Next
        Set rng = rng.End(xlUp).End(xlUp)
        lngTopRow = rng.End(xlUp).Row
    Next
    Application.ScreenUpdating = True
End Sub

Open in new window

0
Avinash SinghAuthor Commented:
Thnx Subodh Sir for giving ur precious time to this post
and thnx aikimark for giving ur precious time to this post
problem solved
0
Subodh Tiwari (Neeraj)Excel & VBA ExpertCommented:
You're welcome Avinash! Glad I could help.
0
aikimarkCommented:
@Avinash

Does your accepted solution only affect the last three sets of data or all sets?
0
Avinash SinghAuthor Commented:
my accepted solution only affect the last cell of all rows in last 3 tables
0
aikimarkCommented:
Will you ever have more than four 'tables' (sets of data)?  If so, retest your accepted code against five sets.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
VBA

From novice to tech pro — start learning today.