Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,514
Default Dim problems

Use a Variant data type to retrieve the value stored in the defined name,
with the Evaluate() function.


Here's an example...

Sub Setup_WksUI(Optional Wks As Worksheet)
Dim sz As String
Dim vSetting, vSettings
Dim i As Integer

If Wks Is Nothing Then Set Wks = ActiveSheet

vSettings = Split(msUI_SETTINGS, ",")

'The sheet must be visible and not protected to do this
Wks.Unprotect PWRD
Wks.Visible = xlSheetVisible

For i = LBound(vSettings) To UBound(vSettings)
'Determine if the current sheet requires the current setting
vSetting = Empty
On Error Resume Next
If vSettings(i) = "uiScrollArea" Then
Set vSetting = Application.Evaluate("'" & Wks.name & "'!" &
vSettings(i))
Else
vSetting = Wks.Names(vSettings(i)).RefersTo
If Not (vSetting = Empty) Then vSetting =
Application.Evaluate("'" & Wks.name & "'!" & vSettings(i))
End If 'rngCell.Value = "uiScrollArea"
On Error GoTo 0

If Not IsEmpty(vSetting) Then
Select Case vSettings(i)
Case "uiProgRows": If vSetting 0 Then
Wks.Range("A1").Resize(vSetting).EntireRow.Hidden = True
Case "uiProgCols": If vSetting 0 Then
Wks.Range("A1").Resize(, vSetting).EntireColumn.Hidden = True
Case "uiScrollArea": Wks.ScrollArea = vSetting.address
Case "uiSelect": Wks.EnableSelection = vSetting
Case "uiFilter": Wks.EnableAutoFilter = vSetting
Case "uiRowColHdrs": Wks.Activate:
Application.ActiveWindow.DisplayHeadings = vSetting
Case "uiProtect": If vSetting Then wksProtect Wks.name
Case "uiVisible": Wks.Visible = vSetting
Case "uiOutline": Wks.EnableOutlining = vSetting

'Persist any changes the user makes during runtime
Case "uiOutlineR"
If Application.Evaluate("'" & Wks.name & "'!" & "uiSet") = 0
Then Wks.Outline.ShowLevels RowLevels:=vSetting:
Wks.Names("uiSet").RefersTo = "=1"
Case "uiOutlineC"
If Application.Evaluate("'" & Wks.name & "'!" & "uiSet") = 0
Then Wks.Outline.ShowLevels ColumnLevels:=vSetting:
Wks.Names("uiSet").RefersTo = "=1"
End Select 'Case vSettings(i)
End If 'Not IsEmpty(vSetting)
Next

End Sub 'Setup_WksUI()

--
Garry

Free usenet access at http://www.eternal-september.org
ClassicVB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion


Reply
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
aauugghhh...#div/o problems & various average formula problems acbel40 Excel Worksheet Functions 5 October 19th 09 05:00 PM
VBA problems [email protected] Excel Programming 0 August 28th 06 10:20 PM
SP3 problems Ron Weaver Excel Discussion (Misc queries) 3 March 19th 05 04:57 PM
Problems merging an excel file due to code or file problems? Cindy M -WordMVP- Excel Programming 0 September 14th 04 02:58 PM
PS to PDF Problems Jmbostock[_16_] Excel Programming 0 July 24th 04 12:41 AM


All times are GMT +1. The time now is 02:37 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"