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: 1
Default Defining ranges in VB code

Hi,

I'm sorry if this seems so trivial to you but I'm trying
to teach myself Visual Basic using the help facility and a
Microsoft Office2000 VBA Fundamentals book. The first
project I have set myself is to develop a financial
planner, the workbook contains 1 template worksheet, 1
worksheet containing reference data and one sheet per
month. My aim is to copy the template worksheet, rename it
for the current calendar month and define ranges on the
new sheet so values can be brought forward to reflect the
balance of my back account.

I am trying to define named RANGES (using VB code) to the
worksheet by passing 2 string variables to 2 of the
parameters to the ACTIVEWORKBOOK.NAMES.ADD command
The parameters being Name:
and RefersToRange:

At the moment the code gives the appearance of working
though the defined RANGES do not appear in the NAME BOX as
I would expect and therefore I can not access the defined
ranges. The defined RANGEs though do appear if I go to the
Insert drop down menu, select the Name option then Define
option!

The range DefineRanges contains 4 columns of the ranges to
be defined on the new worksheet
Column 1 - name of the range to be defined
e.g. "jandirectdebit" on the monthly worksheet
Column 2 - start of the RefersToR1C1 range
Column 3 - end of the RefersToR1C1 range
Column 4 - RefersTo information

The code reads:
Set r = range("DirectDebitName") 'details of ranges
to be defined
For i = 1 to r.rows.count
strRangeName = r.cells(i, 1)
strStartOfRange = r.cells(i, 2)
strEndOfRange = r.cells(i, 3)
strRefersTo = r.cells(i, 4)

ActiveWorkBook.Names.Add Name:strRangeName,
RefersToR1C1:=strStartOfRange & ":" & sreEndOfRange
Next i

I have also tried
ActiveWorkBook.Names.Add Name:strRangeName,
RefersTo:=strRefersTo

No matter what I try I can not define named ranges

HELP!!!

 
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
Defining Multiple "named" data ranges for Piot Tables in Excel 200 Fatih Can1968 Excel Discussion (Misc queries) 1 March 23rd 07 03:29 PM
Defining a name that represent identical ranges in every sheet Bernard Excel Discussion (Misc queries) 1 August 31st 06 02:18 PM
Defining identical names that represent different ranges of cells Bernard Excel Discussion (Misc queries) 2 August 31st 06 07:54 AM
Defining Ranges Steve Excel Worksheet Functions 5 May 28th 05 07:41 AM
Defining Ranges Greg Ghavalas Excel Programming 2 July 9th 03 10:10 PM


All times are GMT +1. The time now is 09:15 AM.

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

About Us

"It's about Microsoft Excel"