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: 4
Default Chapter 5 professional Excel Development

I have two questions from chapter 5 of "profession excel development"

I am fairly new to vba so forgive me if these are dumb questions

1st
what exactly does this mean (more specifically the part starting with
rngName.Value, "=" & rngSetting.Value)

wksSheet.Names.Add rngName.Value, _
"=" & rngSetting.Value
(see code below)

2nd
can someone explain to me step by step what the Private Function

sSheetTabName(ByRef wkbProject As Workbook, _
ByRef sCodeName As String) As String
does and how it works.

(see bottom of the page)

Option Explicit
Option Private Module


Private Const msFILE_TIME_ENTRY As String = "PetrasTemplate.xls"
Private Const msRNG_NAME_LIST As String = "tblRangeNames"
Private Const msRNG_SHEET_LIST As String = "tblSheetNames"

' 03/15/04 Rob Bovey Ch05 Initial version
'
Public Sub WriteSettings()

Dim rngSheet As Range
Dim rngSheetList As Range
Dim rngName As Range
Dim rngNameList As Range
Dim rngSetting As Range
Dim sSheetTab As String
Dim wkbBook As Workbook
Dim wksSheet As Worksheet




Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual

Set wkbBook = Application.Workbooks(msFILE_TIME_ENTRY)
' The list of worksheets in the first column.
Set rngSheetList = wksUISettings.Range(msRNG_SHEET_LIST)
' The list of setting names in the first row.
Set rngNameList = wksUISettings.Range(msRNG_NAME_LIST)

' The outer loop processes all the worksheets in the
' first column of the table.
For Each rngSheet In rngSheetList

' We need an object reference to the worksheet so we
' can easily add a sheet-level defined name to it.
' The sSheetTabName() function converts a CodeName
' into its corresponding sheet tab name.
sSheetTab = sSheetTabName(wkbBook, rngSheet.Value)
Set wksSheet = wkbBook.Worksheets(sSheetTab)

' The inner loop adds each setting to the current sheet.
' If the setting already exists it will be replaced.
For Each rngName In rngNameList

' The value of the setting is contained in the cell
' where the worksheet row and range name column
' intersect.
Set rngSetting = Intersect(rngSheet.EntireRow, _
rngName.EntireColumn)


' We only create defined names for settings that
' have been given a non-zero-length value.

If Len(rngSetting.Value) 0 Then
wksSheet.Names.Add rngName.Value, _
"=" & rngSetting.Value

End If

Next rngName

Next rngSheet

Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic

End Sub

Private Function sSheetTabName(ByRef wkbProject As Workbook, _
ByRef sCodeName As String) As String

Dim wksSheet As Worksheet
For Each wksSheet In wkbProject.Worksheets
If wksSheet.CodeName = sCodeName Then 'sCodeName is paremeter in
argument
sSheetTabName = wksSheet.Name
Exit For
End If
Next wksSheet
End Function




 
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
can you group worksheets together and create a chapter? Daryl Rosenberg Excel Worksheet Functions 1 April 10th 08 08:35 PM
Professional Excel Development E.Q. Excel Discussion (Misc queries) 1 August 17th 06 04:43 AM
Professional Excel Development book question Mark Driscol[_2_] Excel Programming 13 May 6th 06 06:25 PM
Professional Data Recovery Software Development Help rajnishparihar Excel Discussion (Misc queries) 0 July 14th 05 09:40 AM
Chapter numbers hogon Excel Discussion (Misc queries) 1 April 19th 05 07:20 PM


All times are GMT +1. The time now is 07:48 PM.

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"