filter operation inside a function

cvraman

New Member
Joined
Dec 26, 2015
Messages
12
Hi Guys,
Im quite on a basic level in vba so sorry if the question is absurd.

I wanted to filter to a specific element copy all filtered date to a new sheet and do some operations on the new sheet.
I wanted to solve it with a function like this:
Function poc3_vlan(node As String) --> node would be the filer criteria but the filtering is not working if I use a function:
Code:
Function f_node(node As String)


ActiveSheet.Range("A:BB").AutoFilter Field:=5, Criteria1:=xxx
Cells.Select
Application.CutCopyMode = False
    Selection.Copy
    Sheets("Sheet2").Select
    Cells.Select
    ActiveSheet.Paste


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

Ive tried with caling a sub also:
Code:
Function f_node(node As String)


Call s_node(node)
End Function


Sub s_node(target as string)


ActiveSheet.Range("A:BB").AutoFilter Field:=5, Criteria1:=target
Cells.Select
Application.CutCopyMode = False
    Selection.Copy
    Sheets("Sheet2").Select
    Cells.Select
    ActiveSheet.Paste
End Sub


So basically at the first step Im just intrested how to solve the filter,select etc in a function.

Please help me how to do it
thanks
 
Last edited by a moderator:

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
If you are trying to call the function from a cell, it won't work. You can't do anything with a function called from a cell that affects the Excel environment other than return a value to that cell.
 
Upvote 0

Forum statistics

Threads
1,216,116
Messages
6,128,929
Members
449,479
Latest member
nana abanyin

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top