Jump to content

After setting a filter in excel, How to copy the results to new sheet?


Recommended Posts

First time using the excel UDF, I have managed to write a simple script that just simply applys 2 filters and then sorts them in order. I need to copy the results after the filter is set to a new sheet. I did manage to pull somthing together but that copied the entire document over and i just need the ones applied after the filter. Or alternatively just delete all the rows that are not picked up in the filter.

 

I tried messing with " _Excel_RangeCopyPaste " and _Excel_RangeDelete  but i just can't seem to get the hang of it. IF anyone could be kind enough to push me in the right direction I would really appreciate it!

 

Thanks

 

This is what i have so far, i know its basic but it does exactly what i needed it to.

#include <Excel.au3>
#include <Array.au3>

HotKeySet("{ESC}", "On_Exit")
HotKeySet("{F1}", "FilterSheet")
HotKeySet("{F2}", "test")

global $workbook = _Excel_BookAttach("Book1")
if @error Then
   MsgBox("", "Error", "Could not attach")
Else
   MsgBox("", "Attached", "Attached Successfully")
EndIf

while 1
   Sleep(50)
WEnd

func FilterSheet()
_Excel_FilterSet($workbook, Default, Default, 12, "<0")
_Excel_FilterSet($workbook, Default, Default, 4, ">1")
_Excel_RangeSort($workbook, Default, Default, "L:L", Default, Default, $xlYes)
EndFunc
    

func test()
$aResult = _Excel_RangeFind($workbook, "<1")

EndFunc

func On_Exit()
Exit
EndFunc

 

 

Edited by Clerythecleric
Link to comment
Share on other sites

An example can be found in the wiki.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...