[QUOTE=Camlamb28;3605085]Hey all,
This is exactly the thing I'm trying to do, except take a range which goes to the right instead of downwards.
I tried:
But came up with error 1004 (Application or object defined error)Code:Range("C39:" & Range("C39").End(xlRight).Column & "39").Name = "REPS"
Complicate but works:
Range("B3:" & Left(Range("B3").End(xlToRight).Address(ColumnAbsolute:=False), InStr(Range("B3").End(xlToRight).Address(ColumnAbsolute:=False), "$") - 1) & Range("B3").End(xlDown).Row).Select
Of course you can replace '.Select' with '.Name = "REPS"'
Range("B3").CurrentRegion.Name = "REPS" will also works but you must be careful because it will consider any region where B3 belongs (ie it could select cells to the left and up from B3
Cheers
Last edited by Smora; Apr 17th, 2014 at 04:46 PM.
Generally, it is best to avoid using "Selection" programmatically. It is useful for interacting with the user (User to VBA or VBA to User) but if it is being used "within the code" there is almost always a better way to execute an action. In this case, this code can be shortened to:
Code:Range("C39", Range("C39").End(xlToRight)).Name = "REPS"
Like this thread? Share it with others