LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 345
Default Named Ranges vs. Constant Addresses, sheet protection, Guidance.

Hi All,
I am learning about named ranges, so please bear with me.
I have an Addin holding template sheets copied to the user's workbook.

I'm looking for the 'best' way to go forward as I'm having unanticipated
problems with the named ranges, and am at a point in time where
I have to pick one way to go.

1. Can you use named ranges to copy values from locked cells on a
protected sheet? I'm getting intermittent errors.

I just realized that the Insert Define Name menu path is grayed out
on a protected sheet. (Shoulda been a 'heads up' to me, but wasn't)


Up 'til now I've been using public constants in the addin such as:

Public Const sTotRng = "D27" ' users workbook is referenced to the addin.

and then using code like: varname = UserWs.range(sTotRng).value

I thought there was value in establishing a named range, versus changing
a lot of constants for cell ranges, but see below.

MdlWs is an addin template sheet.

Mdlws.range(sTotRng).Copy Destination:=UserWs.range(sTotRng)

has been working when refreshing the user's sheet for formats, etc.
The above also worked fine when copying from a protected sheet in the
addin.


2. What can you tell me about why the commented line in the ExpenseAdd:
routine below did not work ?

As a workaround, I wrote the function below it to give me the
equivalent of my public constant method, it worked, but then, why go thru all
the trouble ? Maybe my "constant" method is the way to go.

3. Over time, if the layout of the MdlWs templates changes, changing
the constants for cell addresses does not seem too different from
changing the named ranges.

Your thoughts ??

Thanks,
Neal


ExpenseAdd: 'Copy from model. money cell + literal.

' line below gets 1004 error, the value of gWktExpenLitRng is the
' named range. Lines below it were the workaround.

' MdlWs.Range(gWktExpenLitRng).Copy _
Destination:=UserWs.Range(gWktExpenLitRng)

CellAdr = sCellAdr_vsRefToF(Wbk.Names(gWktExpenLitRng).Refer sTo)
'CellAdr dimmed as string

MdlWs.Range(CellAdr).Copy Destination:=UserWs.Range(CellAdr)
Return


Public Function sCellAdr_vsRefToF(sRefersTo As String) As String

'Return plain address portion from "=!$a$1" .Names(xxxx).RefersTo
' also: "=!$a$1:$b$2,!$c$3:$d$4"

Dim Text As String, iByte As Integer

iByte = InStr(sRefersTo, "!")
Text = Right(sRefersTo, Len(sRefersTo) - iByte)
Text = Replace(Text, "!", "")
sCellAdr_vsRefToF = Text

End Function
--
Neal Z
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Named ranges scope / workbook/worksheet level named ranges- changeswith variable use... christian_spaceman Excel Programming 3 December 24th 07 01:15 PM
retrieving named ranges from another sheet [email protected] Excel Programming 2 August 10th 07 05:44 PM
Convert Named Ranges to Addresses Pflugs Excel Programming 4 August 6th 07 08:16 PM
Validation protection with named ranges Ben H Excel Worksheet Functions 1 March 17th 06 03:49 AM
Copying named ranges from one sheet to another Mark Stephens Excel Programming 3 August 4th 05 02:54 PM


All times are GMT +1. The time now is 11:24 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"