Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default Use Function to Get Filtered Data From Another Sheet

My sub code works fine. But if I turn it into function, it fails. Can I
use a function to get a result from another sheet?

What I am doing is to put the function in sheet1, then the function
will activate sheet2 where it filters a table and get a sum of a column

Thank you

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Use Function to Get Filtered Data From Another Sheet

do you mean a function used as a formula in a worksheet like

=MyCustomfuction(Sheet2!A1:Z26,3)

A function can't activate or select. but most of the time you don't need to.

so yes, I would say it can do what you ask, but you will need to clean up
your code.

--
Regards,
Tom Ogilvy


"Who I Am" wrote:

My sub code works fine. But if I turn it into function, it fails. Can I
use a function to get a result from another sheet?

What I am doing is to put the function in sheet1, then the function
will activate sheet2 where it filters a table and get a sum of a column

Thank you


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default Use Function to Get Filtered Data From Another Sheet

Hi Mr. MVP:

Here is my code. It works. But I have to read the message box and copy
it to my spreadsheet. I want to use function to get the result.

I put it into

Function MonthBillng()
End Function

But it did not work. (I want to put the function in sheet1 and to get
the data from sheet19)

=============================================

Sub MonthBilling()

Dim TotalBilling

Sheet19.Activate
ActiveSheet.Range("A4").Select
Selection.AutoFilter Field:=7, Criteria1:="<N/A*", Operator:=xlAnd

ActiveSheet.Range("M4").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.SpecialCells(xlCellTypeVisible).Select

TotalBilling = Format(WorksheetFunction.Sum(Selection), "$* #,##0")
Sheet1.Activate

MsgBox TotalBilling

End Sub




Tom Ogilvy wrote:
do you mean a function used as a formula in a worksheet like

=MyCustomfuction(Sheet2!A1:Z26,3)

A function can't activate or select. but most of the time you don't need to.

so yes, I would say it can do what you ask, but you will need to clean up
your code.

--
Regards,
Tom Ogilvy


"Who I Am" wrote:

My sub code works fine. But if I turn it into function, it fails. Can I
use a function to get a result from another sheet?

What I am doing is to put the function in sheet1, then the function
will activate sheet2 where it filters a table and get a sum of a column

Thank you



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
use a function for filtered data debl Excel Worksheet Functions 7 August 6th 09 04:57 PM
How do you copy filtered data to a new sheet? Kerry B Excel Discussion (Misc queries) 3 July 31st 07 08:48 PM
Updated filtered data on next sheet FARAZ QURESHI Excel Discussion (Misc queries) 0 January 1st 07 10:26 PM
Help to sort out filtered data from the data contained in another sheet of the same workbook No News Excel Worksheet Functions 1 July 28th 06 04:04 PM
Trasnsposing or copying filtered data from one sheet to another Sierras Excel Worksheet Functions 1 January 14th 06 05:24 PM


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