![]() |
Name Issue
Hi all,
the following is my current code: For Each t In Sheets("Tasks").Range("A2:A500") I'd like to define a name refer to ("A2:A500") and use that name in the above code, how can I do it. Clara -- thank you so much for your help |
Name Issue
Dim clara as String
clara="A2:A500" For Each t In Sheets("Tasks").Range(clara) -- Gary''s Student - gsnu200793 "clara" wrote: Hi all, the following is my current code: For Each t In Sheets("Tasks").Range("A2:A500") I'd like to define a name refer to ("A2:A500") and use that name in the above code, how can I do it. Clara -- thank you so much for your help |
Name Issue
Here is one way:
Sub fh() Sheets(1).Range("B2:B5").Name = "SomeName" End Sub You can also just use a variable for code purposes: SomeName = Range("B2:B5") The difference is that when you use the range name as the object it would be Range("SomeName") and is a range object. The other would be a variable that could be used as a value - SomeName - or a range - SomeName.Address and a few other variations depending on your declarations. "clara" wrote: Hi all, the following is my current code: For Each t In Sheets("Tasks").Range("A2:A500") I'd like to define a name refer to ("A2:A500") and use that name in the above code, how can I do it. Clara -- thank you so much for your help |
Name Issue
Hi JLGWhiz
thank you for your help Clara -- thank you so much for your help "JLGWhiz" wrote: Here is one way: Sub fh() Sheets(1).Range("B2:B5").Name = "SomeName" End Sub You can also just use a variable for code purposes: SomeName = Range("B2:B5") The difference is that when you use the range name as the object it would be Range("SomeName") and is a range object. The other would be a variable that could be used as a value - SomeName - or a range - SomeName.Address and a few other variations depending on your declarations. "clara" wrote: Hi all, the following is my current code: For Each t In Sheets("Tasks").Range("A2:A500") I'd like to define a name refer to ("A2:A500") and use that name in the above code, how can I do it. Clara -- thank you so much for your help |
Name Issue
Hi Gary,
thank you for your help -- thank you so much for your help "Gary''s Student" wrote: Dim clara as String clara="A2:A500" For Each t In Sheets("Tasks").Range(clara) -- Gary''s Student - gsnu200793 "clara" wrote: Hi all, the following is my current code: For Each t In Sheets("Tasks").Range("A2:A500") I'd like to define a name refer to ("A2:A500") and use that name in the above code, how can I do it. Clara -- thank you so much for your help |
All times are GMT +1. The time now is 02:20 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com