• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Named Range

Sukumar

New Member
Hi,

Is it possibile to Name a Range (for example, "$A$1:$AI$3210" as NewRange) and then use it in following code: -

Code:
Dim LastRowofSheet As Long
            Dim LastColnofSheet As Long
   
            LastRowofSheet = Cells(Rows.Count, 1).End(xlUp).Row
            LastColnofSheet = Cells(1, Columns.Count).End(xlToLeft).Column
           
            ActiveSheet.Range("$A$1:$AI$3210").AutoFilter Field:=1, Criteria1:="=2200*", Operator:=xlAnd
 
Code:
Dim LastRowofSheet As Long
            Dim LastColnofSheet As Long
   
            LastRowofSheet = Cells(Rows.Count, 1).End(xlUp).Row
            LastColnofSheet = Cells(1, Columns.Count).End(xlToLeft).Column
  ActiveWorkbook.Names.Add Name:="NewRange", RefersToR1C1:="=Sheet1!R1C1:R3210C35"           
            ActiveSheet.Range("NewRange").AutoFilter Field:=1, Criteria1:="=2200*", Operator:=xlAnd
 
Hi,

Thank you,

I changed this code to following: -

Code:
 ActiveWorkbook.Names.Add Name:="NewRange", RefersToR1C1:="=R2C1:R" & LastRowofSheet & "C" & LastColnofSheet
 
Back
Top