LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 41
Default Add sheet name into a variable.

Hi

I am wanting to amend a range defined in my db to a named range.
I have a named range on different worksheets such as:

Sheet1Week1
Sheet2Week2

My formula is:

Application.WorksheetFunction. _CountIf(ws.Range("$G$4:$H$44"),
"Banana")

I want to change $G$4:$H:44 as a named range Sheet1Week1 or whatever
the worksheet is so "wsWeek1". (taking I have defined ws as the
ActiveSheet)

1. How do get the range defined, im not sure how to make a variable
take text as a value?

Dim Week1Range, Week2Range
Dim ws
ws = ActiveSheet
Week1range= ws & "Week1"
Week2range= ws & "Week2"

2. Once I have defined Week1range as Sheet1Week1 how do I put this
into my formula? So replace:

Application.WorksheetFunction. _CountIf(ws.Range("$G$4:$H$44"),
"Banana")

with

Application.WorksheetFunction. _CountIf(ws.Range(Week1range),
"Banana")

Cheers

Rich





 
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
variable sheet name Gisela Excel Discussion (Misc queries) 6 September 14th 09 01:25 PM
Hide a sheet with a variable name Scott Excel Worksheet Functions 4 July 11th 08 08:21 AM
How To make a sheet reference Variable (eq: sum(sheet!D2:H2)) John Linker Excel Discussion (Misc queries) 3 June 16th 08 11:29 PM
Variable sheet and Formula Sheet Emmett423 Excel Discussion (Misc queries) 2 March 31st 06 02:14 AM
variable in a link where the variable is the name of the sheet darrelly Excel Worksheet Functions 1 October 7th 05 08:24 AM


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