Globally Named Range Problem

A

Arturo

Hello,
I’m wondering if there’s away to add a named range to a specified sheet
without selecting that sheet first. I can get a row count from a sheet while
it’s not active…

Public MASTERwb As Workbook

Sub ScaleVLU()
Dim RowCnt As Integer

Set MASTERwb = ActiveWorkbook
MASTERwb.Sheets(“abcâ€).Select
RowCnt = MASTERwb.Sheets(“abcâ€).UsedRange.Rows.Count
MASTERwb.Names.Add Name:="VLU", _
RefersTo:="=" & MASTERwb.Sheets(“abcâ€).Range("A1:D" & RowCnt).Address
End Sub

Appreciatively,
Arturo
 
B

Bob Phillips

Public MASTERwb As Workbook

Sub ScaleVLU()
Dim RowCnt As Integer

Set MASTERwb = ActiveWorkbook
MASTERwb.Sheets("abc").Select
RowCnt = MASTERwb.Sheets("abc").UsedRange.Rows.Count
MASTERwb.Names.Add Name:="abc!VLU", _
RefersTo:="=" & MASTERwb.Sheets("abc").Range("A1:D" &
RowCnt).Address
End Sub


--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)
 
B

Bob Phillips

That is what you asked for.

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)
 
A

Arturo

Bob,
I apologize if I was unclear; there are additional pieces that weren’t
mentioned. Another sub accesses that global VLU populating another scalable
range in different sheet. What is resolving the other issues is as follows:

Sub ScaleVLU()
Dim RowCnt_CLS As Integer

Set MASTERwb = ActiveWorkbook
MASTERwb.Sheets(“abcâ€).Select
RowCnt_CLS = MASTERwb.Sheets(“abcâ€).UsedRange.Rows.Count
MASTERwb.Names.Add Name:="VLU", _
RefersTo:="=" & Range("A1:D" & RowCnt_CLS).Address
End Sub

I do appreciate your input.
Best,
Arturo
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top