Using a defined formula in multiple sheet

  • Thread starter Thread starter Roel
  • Start date Start date
R

Roel

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
 
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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top