Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 184
Default ActiveSheet in formula

Hi All,

I have the following formula in vba:

..Formula = "=COUNTIFS('[" & strName & "]Sheet1'!$E:$E,A2,'[" & strName & "]Sheet1'!$H:$H,""0"")"

The file I am referencing via the variable strName only has one sheet...but what I am finding is that the sheet name is not always Sheet1. How can I modify the formula to select the only sheet in the workbook?

Thanks!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 449
Default ActiveSheet in formula

Hi

Try replacing

Sheet1

with

" & Workbooks(strName).Sheets(1).Name & "

HTH. Best wishes Harald

"Steve" wrote in message
news:3109790.209.1332264505214.JavaMail.geo-discussion-forums@ynbu11...
Hi All,

I have the following formula in vba:

.Formula = "=COUNTIFS('[" & strName & "]Sheet1'!$E:$E,A2,'[" & strName &
"]Sheet1'!$H:$H,""0"")"

The file I am referencing via the variable strName only has one
sheet...but what I am finding is that the sheet name is not always Sheet1.
How can I modify the formula to select the only sheet in the workbook?

Thanks!


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 538
Default ActiveSheet in formula

Harald Staff wrote:

"Steve" wrote in message
news:3109790.209.1332264505214.JavaMail.geo-discussion-forums@ynbu11...

I have the following formula in vba:

.Formula = "=COUNTIFS('[" & strName & "]Sheet1'!$E:$E,A2,'[" & strName &
"]Sheet1'!$H:$H,""0"")"

The file I am referencing via the variable strName only has one
sheet...but what I am finding is that the sheet name is not always Sheet1.
How can I modify the formula to select the only sheet in the workbook?


Try replacing

Sheet1

with

" & Workbooks(strName).Sheets(1).Name & "


Alternately, ActiveCell.Parent.Name would also work (or in the specific code
Steve posted, just .Parent.Name). As the Perl slogan says, there's more than
one way to do it.

--
I'll be honest.
I have no freakin' clue what these people are trying to accomplish.
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 184
Default ActiveSheet in formula

Awesome. Thanks guys!

On Tuesday, March 20, 2012 11:28:25 AM UTC-6, Steve wrote:
Hi All,

I have the following formula in vba:

.Formula = "=COUNTIFS('[" & strName & "]Sheet1'!$E:$E,A2,'[" & strName & "]Sheet1'!$H:$H,""0"")"

The file I am referencing via the variable strName only has one sheet...but what I am finding is that the sheet name is not always Sheet1. How can I modify the formula to select the only sheet in the workbook?

Thanks!


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
Vba Formula To Include Activesheet Name LuisE Excel Programming 3 March 25th 09 02:57 AM
Use a password in VBA ActiveSheet.protect & ActiveSheet.unprotect? Jim K. Excel Programming 2 June 2nd 08 08:09 PM
Copying new activesheet after other activesheet is hidden? Simon Lloyd[_790_] Excel Programming 1 June 20th 06 10:02 AM
activesheet Jim at Eagle Excel Programming 1 April 6th 05 12:21 AM
ActiveSheet Ron de Bruin Excel Programming 0 July 29th 03 04:59 PM


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