|
-
Jul 3rd, 2006, 02:18 AM
#1
Excel: set a range by its name [SELF-RESOLVED]
I have this VBA code in a Excel spreadsheet:
VB Code:
Dim vTarget As range
Private Sub Workbook_Open()
Set vTarget = Range("Sheet1!$B$3")
End Sub
Now, cell $B$3 has been assigned the name "Volume". I want to set the vTarget variable using the name "Volume" rather than the cell address. I've tried different syntax but always get some kind of error.
Last edited by krtxmrtz; Jul 3rd, 2006 at 06:50 AM.
Lottery is a tax on people who are bad at maths
If only mosquitoes sucked fat instead of blood...
To do is to be (Descartes). To be is to do (Sartre). To be do be do (Sinatra)
-
Jul 3rd, 2006, 06:50 AM
#2
Re: Excel: set a range by its name
VB Code:
Dim vTarget As range
Private Sub Workbook_Open()
Set vTarget = Range(ThisWorkbook.Names("Volume"))
End Sub
It wasn't that difficult after all.
Lottery is a tax on people who are bad at maths
If only mosquitoes sucked fat instead of blood...
To do is to be (Descartes). To be is to do (Sartre). To be do be do (Sinatra)
-
Jul 3rd, 2006, 04:50 PM
#3
Re: Excel: set a range by its name [SELF-RESOLVED]
VB Code:
Private Sub Workbook_Open()
Dim vTarget As range
Set vTarget = Range("Volume")
End Sub
That will also work.
zaza
-
Jul 4th, 2006, 06:41 AM
#4
Re: Excel: set a range by its name [SELF-RESOLVED]
 Originally Posted by zaza
VB Code:
Private Sub Workbook_Open()
Dim vTarget As range
Set vTarget = Range("Volume")
End Sub
That will also work.
zaza
Right, thanks for pointing out.
Lottery is a tax on people who are bad at maths
If only mosquitoes sucked fat instead of blood...
To do is to be (Descartes). To be is to do (Sartre). To be do be do (Sinatra)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|