Macro to clear Text on last sheet

howard

Well-known Member
Joined
Jun 26, 2006
Messages
6,561
Office Version
  1. 2021
Platform
  1. Windows
I would like to clear all text below the last value in Col BA and 10 cols to the right on the last sheet


I have tried to right code to do this but the text is not cleared

It would be appreciated if someone could assist me


Code:
 Sub Clear_UnwantedTextlastRow()
Dim LastRow As Double
Dim LastCol As Double
    Dim RowCtr As Double

    LastRow = Cells(Rows.Count, "BA").End(xlUp).Row
LastCol = Cells(1, Columns.Count).End(xlToLeft).Column
    Cells(53, LastCol + 1) = "Product Cost"

   
For RowCtr = 2 To LastRow
Cells(RowCtr, LastCol + 1).Resize(, 10).ClearContents

    Next RowCtr


End Sub
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
One way maybe

VBA Code:
Sub Clear_UnwantedTextlastRow()
    Dim BA_Last As Range
    With Sheets(Sheets.Count)
        Set BA_Last = .Range("BA:BA").Find("*", , xlValues, , xlByRows, xlPrevious).Offset(1)
 
        Range(BA_Last, .Cells(.Cells.Find("*", , xlValues, , xlByRows, xlPrevious).Row, BA_Last.Offset(, 10).Column)).ClearContents
    End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,925
Messages
6,122,298
Members
449,077
Latest member
Rkmenon

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top