Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Using a defined formula in multiple sheet

Hi,

I would like to define a general function to use in multiple sheets. The
formula is a lookup funcion that looks within the sheet. Is it possible to
let it only look at the current sheet and not let it use the same values in
other sheets?

Here is a sample of my function:
-----------------------
Function Alpha(A, B)

Application.Volatile (True)

Reset_Arrays

Worksheets(B).Select

m = 1

For i = 6 To 350
If Left(Cells(i, 15), 1) = "Z" Or Left(Cells(i, 15), 1) = "X" Or
Left(Cells(i, 15), 2) = "TV" Or Left(Cells(i, 15), 2) = "VP" Or
Left(Cells(i, 15), 2) = "VU" Or Left(Cells(i, 15), 2) = "A-" Then
Current(m, 1, B) = Cells(i, 16)
Current(m, 2, B) = Cells(i, 17)
Current(m, 3, B) = Cells(i, 18)
m = m + 1
End If
Next

For i = 1 To m
Alpha = Alpha + Current(i, A, B)
Next

End Function
-------------------------------

When I use it, it will show up the same values in any worksheet this formula
is defined. I hope this makes sense. It is really driving me crazy.

Thank you in advance

Roel Balbin
Accounting/Sales Support
Teragren, LLC


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default Using a defined formula in multiple sheet

Hi
problem is that you hardcoded worksheet B in this function. Why don't
you sue the cell range to be processed as parameter in your function?

--
Regards
Frank Kabel
Frankfurt, Germany

"Roel" schrieb im Newsbeitrag
...
Hi,

I would like to define a general function to use in multiple

sheets. The
formula is a lookup funcion that looks within the sheet. Is it

possible to
let it only look at the current sheet and not let it use the same

values in
other sheets?

Here is a sample of my function:
-----------------------
Function Alpha(A, B)

Application.Volatile (True)

Reset_Arrays

Worksheets(B).Select

m = 1

For i = 6 To 350
If Left(Cells(i, 15), 1) = "Z" Or Left(Cells(i, 15), 1) = "X" Or
Left(Cells(i, 15), 2) = "TV" Or Left(Cells(i, 15), 2) = "VP" Or
Left(Cells(i, 15), 2) = "VU" Or Left(Cells(i, 15), 2) = "A-" Then
Current(m, 1, B) = Cells(i, 16)
Current(m, 2, B) = Cells(i, 17)
Current(m, 3, B) = Cells(i, 18)
m = m + 1
End If
Next

For i = 1 To m
Alpha = Alpha + Current(i, A, B)
Next

End Function
-------------------------------

When I use it, it will show up the same values in any worksheet this

formula
is defined. I hope this makes sense. It is really driving me crazy.

Thank you in advance

Roel Balbin
Accounting/Sales Support
Teragren, LLC



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
INDIRECT with Sheet Level Defined Name NickH Excel Worksheet Functions 2 June 22nd 11 06:07 PM
use functions on defined multiple range rolando Excel Worksheet Functions 5 March 3rd 09 06:35 PM
defined sheet formula to vb code [email protected] Excel Discussion (Misc queries) 2 November 28th 06 08:02 PM
Changing Multiple Defined Names At Once? Wuddus Excel Discussion (Misc queries) 3 September 26th 06 12:57 AM
Using non defined names from another sheet pQp Excel Worksheet Functions 6 July 17th 05 11:06 PM


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