about Used range from particular cell

VBABEGINER

Well-known Member
Joined
Jun 15, 2011
Messages
1,284
Office Version
  1. 365
Platform
  1. Windows
Hello All board member,
It seems from very very long time on board..Happy to questioning..

Ok..

I have question like, after my c10 range, whatever be the rows data are there, will be clear..

Can anyone help me on this..
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
I have question like, after my c10 range, whatever be the rows data are there, will be clear..

Can anyone help me on this..
Your question is not entirely clear, but let me take a guess. You want to clear all the cells which, in some way touch cell C10 or another cell that indirectly touches cell C10 through a chain of such cells. That is called the CurrentRegion and you would clear is like this...

Range("C10").CurrentRegion.Clear

You could use ClearContents instead of Clear if you wanted to leave existing formats intact.
 
Upvote 0
If you want to leave everything above row 10 intact, but delete everything below that, try:
Code:
    Dim lastCell As Range
    Set lastCell = ActiveCell.SpecialCells(xlLastCell)
    Range("C10:" & lastCell.Address).EntireRow.ClearContents
If you want to leave columns A and B intact, in addition to everything above row 10, then just change the last row in the code above to:
Code:
    Dim lastCell As Range
    Set lastCell = ActiveCell.SpecialCells(xlLastCell)
    Range("C10:" & lastCell.Address).ClearContents
 
Upvote 0
If you want to leave everything above row 10 intact, but delete everything below that, try:
Code:
    Dim lastCell As Range
    Set lastCell = ActiveCell.SpecialCells(xlLastCell)
    Range("C10:" & lastCell.Address).EntireRow.ClearContents
If you want to leave columns A and B intact, in addition to everything above row 10, then just change the last row in the code above to:
Code:
    Dim lastCell As Range
    Set lastCell = ActiveCell.SpecialCells(xlLastCell)
    Range("C10:" & lastCell.Address).ClearContents


Hi Joe, a problem is that, some scenario...my C last row will be changing. so instead of c i have now taken Col A.
so i take last row of my Col A. And there be a chances like, from Col C to Col K...rows may be multiple.
hence i edit code like this..
Dim LstRw3 As Integer
LstRw3 = Range("A" & Rows.Count).End(xlUp).Row + 1

'If you want to leave everything above row 10 intact, but delete everything below that, try:


Dim lastCell As Range
Set lastCell = ActiveCell.SpecialCells(xlLastCell)
'Range("C10:" & lastCell.Address).EntireRow.ClearContents


Range("A:" LstRw3 & lastCell.Address).EntireRow.ClearContents

but this not working...
could you pls help in this..
 
Upvote 0
You have not built your address properly.
Addresses look like this A1:C10 (column reference, row reference, colon, column reference, row reference).

Try:
Code:
[COLOR=#333333][I]Range("A" & LstRw3 & ":" & lastCell.Address).EntireRow.ClearContents[/I][/COLOR]
 
Upvote 0
Excellent...This works perfect...:-D

Can you also tell me, suppose if only data clear from A2 range...No clearance of headings..

You have not built your address properly.
Addresses look like this A1:C10 (column reference, row reference, colon, column reference, row reference).

Try:
Code:
[COLOR=#333333][I]Range("A" & LstRw3 & ":" & lastCell.Address).EntireRow.ClearContents[/I][/COLOR]
 
Upvote 0
Do you mean what if you want to delete everything except for headers?
Then just hard-code in your starting address, i.e.
Code:
[COLOR=#333333]Range("A2:" & lastCell.Address).EntireRow.ClearContents[/COLOR]
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,324
Members
452,635
Latest member
laura12345

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