Range variable range.rows.count

288enzo

Well-known Member
Joined
Feb 8, 2009
Messages
721
Office Version
  1. 2016
Platform
  1. Windows
I don't understand why this doesn't work. If I replace rng with the actual range Range("B4:D" & Range("A" & Rows.Count).End(xlUp).Row) it does.

VBA Code:
    Dim rng As Range
    
    rng = Range("B4:D" & Range("A" & Rows.Count).End(xlUp).Row)
        
    rng.NumberFormat = "0%"

    rng.FormatConditions.Add Type:=xlTextString, String:="N/A", TextOperator:=xlContains
    rng.FormatConditions(1).Interior.Color = 3355443
    rng.FormatConditions(1).Font.ThemeColor = xlThemeColorDark1
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
That code will return an error on the rng =line.
Also your code does not seem to have any relevance to your question.
 
Upvote 0
That code will return an error on the rng =line.
Also your code does not seem to have any relevance to your question.
Thanks for pointing that out. I was missing Set
Set rng = Range("B4:D" & Range("A" & Rows.Count).End(xlUp).Row)
 
Upvote 0

Forum statistics

Threads
1,214,935
Messages
6,122,337
Members
449,078
Latest member
skydd

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