Set Range to Unknown Range - vba Code

Plokimu77

Board Regular
Joined
Oct 1, 2014
Messages
138
Good Morning,

Can someone help me modify my code, to select all the rows available starting in B1 ?
The range of rows can vary so basically its unknown to me, until I pull the data from my source.

Thank you


VBA Code:
Sub Test()
Dim rng As Range, rcell As Range
Set rng = Range("B1:B23")
For Each rcell In rng.SpecialCells(xlCellTypeBlanks)
If Application.CountIf(rcell.Resize(, 18), "<>") = 0 Then
rcell.Resize(, 13).Interior.ColorIndex = 15
End If
Next rcell
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
Try...
VBA Code:
Set rng = Range("B1:B" & Range("B" & Rows.count).End(xlUp).Row)
 
Upvote 0
Solution
One more request.

(sorry, it just came to my mind as I was analyzing my data)

In addition, could it be possible to change the height of the blank rows to RowHeight = 6, as well?

Thank you


VBA Code:
Sub Test()

Dim rng As Range, rcell As Range
       Set rng = Range("B1:B" & Range("B" & Rows.count).End(xlUp).Row)

For Each rcell In rng.SpecialCells(xlCellTypeBlanks)
If Application.CountIf(rcell.Resize(, 18), "<>") = 0 Then
rcell.Resize(, 13).Interior.ColorIndex = 15
End If
Next rcell

End Sub
 
Upvote 0
VBA Code:
Sub Test()

    Dim rng As Range, rcell As Range
    Set rng = Range("B1:B" & Range("B" & Rows.Count).End(xlUp).Row)

    For Each rcell In rng.SpecialCells(xlCellTypeBlanks)
        
        If Application.CountIf(rcell.Resize(, 18), "<>") = 0 Then
            rcell.Resize(, 13).Interior.ColorIndex = 15
            rcell.EntireRow.RowHeight = 6
        End If
    
    Next rcell

End Sub
 
Upvote 0

Forum statistics

Threads
1,215,102
Messages
6,123,099
Members
449,096
Latest member
provoking

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