VBA coding - SET RNG

btsboarder

New Member
Joined
Jun 28, 2013
Messages
9
Hi All,

I am trying to have my VBA code grab all the information in the relevant range, but not pick up any empty lines, i.e stop when there is no more information. This is the code I have right now.

Set rng = Nothing
Set rng = Range("B5:H31").SpecialCells(xlCellTypeVisible)

So say my information only goes to row 20, I don't want it to continue until row 31. I have it set up to paste the information into an email, so I want to cut down on white noise.

Thanks!
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
Maybe:
set rng = range("B5:H" & range("B5").end(xldown).row)

Cell type visible works with hidden rows, not just empty rows. Using xldown will be the equivalent of selecting B5 and then hitting Ctrl + down arrow.
 
Upvote 0
So I have a range that has formulas in rows B:H to row 30. So the control down will select the formulas. They pull if information is entered in column A. So if now information is given in column A, it'll be blank. But that code still thinks control down to the end. Thoughts?
 
Upvote 0
pplstuff was on the right track, but now that we know column B is filled with formulas referring to column A, then we can use column A to find the last row

Try
set rng = range("B5:H" & range("A5").end(xldown).row)
 
Last edited:
Upvote 0

Forum statistics

Threads
1,216,030
Messages
6,128,408
Members
449,448
Latest member
Andrew Slatter

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