set a range to non-blank cells within a range?

danno79

New Member
Joined
Oct 28, 2009
Messages
45
I'm trying to set a range equal to the nonblank cells within range I81 and I111 (number of no blanks changes). Cells with data in are always at the top of the range with no blanks separating.

At the moment I am setting the range by manually altering the last cell in the range any ideas how to achieve this automatically greatly apreciated.:)


Rich (BB code):
Set rSrc = Range("l80:(last non blank cell up to l111)")
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
Code:
Set rSrc= Range("I81:I" & Cells(Rows.Count,"I").End(xlUp).Row)
Or maybe you need
Code:
Set rSrc= Range("I81:I" & Range("I1111").End(xlUp).Row)
lenze
 
Last edited:
Upvote 0
Thanks lenze the first worked just fine for me - i figured there was a fairly simple way to do it just wasn't sure of the syntax ;)
 
Upvote 0

Forum statistics

Threads
1,215,364
Messages
6,124,507
Members
449,166
Latest member
hokjock

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