Excel VBA - Clearing Cells from a Specific Row

Grothgar

Board Regular
Joined
Jul 25, 2011
Messages
62
Hello All;

I have the following problem that I need to solve using VBA... I have a sort of solution, but I am sure there are people here with much more knowledge than myself.

So, what I need the Macro to do is, go down to a certain cell from a starting position, and then clear the Rows from one below the last filled cell.

I know how to start this
Code:
Range("L7").Select
Selection.End(xlDown).Offset(1, 0).Select

This gets me to the row below the last filled cell, but I have no idea how to get it to select the Rows, rather than just the cell.

Any help would be appreciated.:confused:
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
I am not quite certain it is clear exactly which rows you are trying to clear. Perhaps walking us through a simple example will clarify it.

Also, do you want to delete the rows, or just clear the contents of all cells in those rows?
 
Upvote 0
I am not quite certain it is clear exactly which rows you are trying to clear. Perhaps walking us through a simple example will clarify it.

Also, do you want to delete the rows, or just clear the contents of all cells in those rows?

I am trying to clear the rows below the last amount of data in Column L.
So, if data is in cell L56, then I would want to clear rows 57 down.

And, I am looking to just clear the contents, not delete the rows
 
Upvote 0
OK, so there is no data in column L below 56. Which column can you use to determine how far down you need to go?
 
Upvote 0
From your description, this should work:
Code:
Public Sub ClearContents()
Dim lLR As Long
lLR = Range("L7").End(xlDown).Offset(1, 0).Row
Range("L" & lLR & ":L" & Rows.Count).EntireRow.ClearContents
End Sub

But try it on a backup sheet first!
 
Upvote 0
From your description, this should work:
Code:
Public Sub ClearContents()
Dim lLR As Long
lLR = Range("L7").End(xlDown).Offset(1, 0).Row
Range("L" & lLR & ":L" & Rows.Count).EntireRow.ClearContents
End Sub

But try it on a backup sheet first!


Loving it!
That works in exactly the way that I desired... thank you very much. :)
 
Upvote 0

Forum statistics

Threads
1,224,592
Messages
6,179,789
Members
452,942
Latest member
VijayNewtoExcel

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