PC Review


Reply
Thread Tools Rate Thread

Collecting Range Name values to VBA

 
 
John
Guest
Posts: n/a
 
      18th Feb 2010
I have a worksheet "Setup" where users type in a date in a cell named
"ChtDte" and a path and database name in a cell named "FLName". I am using
DOA to connect to a database and return a record set. The query used
"qryCOCostwRates" uses a date paramater. Because this sheet will be used by
several users all pointing to the database in different locations, I need to
know where they have the database.

I need to get the values in these two range names in the setup tab of the
spreadsheet so I can connect to the data, and provide a value for the
paramiter. This should be easy but I can't seem to find the solution. Any
ideas? Here's what I have tried:

Dim xlwsSetup As Excel.Worksheet
Dim xlrngFl As Excel.Range
Dim xlrngDte As Excel.Range
Dim xlWb As Excel.Workbook
Dim dbFln as String
Dim RptDte as Date
Set xlWb = ActiveWorkbook
Set xlwsSetup = xlWb.Worksheets("Sheet3")
Set xlwsSetup = ActiveSheet
Set xlrngFl = xlwsSetup.Range("FlName")

'The above is cell C3 but it may change so I named the range "FLName". The
user types "C:\Data\db\mydb.mdb" into the cell.

Set xlrngDte = xlwsSetup.Range("ChtDte")
'The above is cell C2 and it has a date in it like 2/28/09. If rows or
columns are inserted, I don't want to lose the reference so it's named ChtDte.

dbFln = xlrngFl.Value
RptDte = xlrngDte.Value

Is the file path and name (FLName) and the report date (ChtDte) now in my
variables?


--
Thanks in advance!
**John**
 
Reply With Quote
 
 
 
 
John
Guest
Posts: n/a
 
      19th Feb 2010
I got it worked out... Thanks for all the help...
--
Thanks in advance!
**John**


"John" wrote:

> I have a worksheet "Setup" where users type in a date in a cell named
> "ChtDte" and a path and database name in a cell named "FLName". I am using
> DOA to connect to a database and return a record set. The query used
> "qryCOCostwRates" uses a date paramater. Because this sheet will be used by
> several users all pointing to the database in different locations, I need to
> know where they have the database.
>
> I need to get the values in these two range names in the setup tab of the
> spreadsheet so I can connect to the data, and provide a value for the
> paramiter. This should be easy but I can't seem to find the solution. Any
> ideas? Here's what I have tried:
>
> Dim xlwsSetup As Excel.Worksheet
> Dim xlrngFl As Excel.Range
> Dim xlrngDte As Excel.Range
> Dim xlWb As Excel.Workbook
> Dim dbFln as String
> Dim RptDte as Date
> Set xlWb = ActiveWorkbook
> Set xlwsSetup = xlWb.Worksheets("Sheet3")
> Set xlwsSetup = ActiveSheet
> Set xlrngFl = xlwsSetup.Range("FlName")
>
> 'The above is cell C3 but it may change so I named the range "FLName". The
> user types "C:\Data\db\mydb.mdb" into the cell.
>
> Set xlrngDte = xlwsSetup.Range("ChtDte")
> 'The above is cell C2 and it has a date in it like 2/28/09. If rows or
> columns are inserted, I don't want to lose the reference so it's named ChtDte.
>
> dbFln = xlrngFl.Value
> RptDte = xlrngDte.Value
>
> Is the file path and name (FLName) and the report date (ChtDte) now in my
> variables?
>
>
> --
> Thanks in advance!
> **John**

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem collecting Range Values richcoleuk Microsoft Excel Programming 6 3rd Apr 2006 03:37 PM
Stumped! Collecting values into one cell. AthleteTO Microsoft Excel Worksheet Functions 5 2nd Nov 2004 04:24 PM
Stumped! Collecting values into one cell. AthleteTO Microsoft Excel Worksheet Functions 0 1st Nov 2004 07:29 PM
Collecting values for later display? Ed Microsoft Excel Programming 4 4th Aug 2003 04:50 PM
collecting previous values adil Microsoft Excel Programming 1 31st Jul 2003 04:31 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:49 PM.