Jump to content
AshishS

Select and copy filtered cell in excel - (Moved)

Recommended Posts

Hi friends,

I am new to Autoit and would like to automate excel task. I am trying to bring source formatted vlookup text to another sheet. I am looking for autoit to help me but I got stuck in autoit code. My idea is to select the filtered excel cell value with this code, copy it and paste at destination cell but I don't know how to select specific filtered cell so that I can copy it. Need your help to get rid of this.

$oRange = $oExcel.ActiveSheet.Range("A1:AK871")
For $oRow In $oRange.Rows
    If $oRow.Hidden = False Then
        ConsoleWrite($oRow.Columns(37).Value)
        Send("^c")
    EndIf
Next

Also let me know if there is a better way to do this task in excel only.

Share this post


Link to post
Share on other sites

Welcome to AutoIt and the forum!

How to retrieve all filtered rows can be found in the wiki.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2020-10-10 - Version 1.5.2.1) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2020-06-30 - Version 1.6.2.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (NEW 2020-06-27 - Version 1.3.2.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
Task Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki, WebDriver - Wiki

 

Share this post


Link to post
Share on other sites

Water, Thanks for reply.

I don't need to store my data in array or variable, as it will not copy the source formatting.

I just need to select the filtered specific cell and copy that output in excel and paste at destination.

Share this post


Link to post
Share on other sites

It is much more simple and efficient to store it in an array and write it to the target excel destination.  Copy / paste is for human.  Arrays are for machine.  Take the suggestion of @water and look at _Excel_RangeWrite.  You will get script in no time...

Share this post


Link to post
Share on other sites

As $oArea is a Range object you could use function _Excel_CopyPaste to copy each Area of the filtered sheet.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2020-10-10 - Version 1.5.2.1) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2020-06-30 - Version 1.6.2.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (NEW 2020-06-27 - Version 1.3.2.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
Task Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki, WebDriver - Wiki

 

Share this post


Link to post
Share on other sites

Moved to the appropriate forum, as the Developer General Discussion forum very clearly states:

Quote

General development and scripting discussions. If it's super geeky and you don't know where to put it - it's probably here.


Do not create AutoIt-related topics here, use the AutoIt General Help and Support or AutoIt Technical Discussion forums.

Moderation Team


"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Share this post


Link to post
Share on other sites

Thanks all for your reply.

Hey @water,

I implemented _ExcelRangeCopyPaste and it works great for me. Thanks a ton!

Only problem is that it will copy the header cell as well, which is not required. Please help me to find where I am wrong.

Thanks in advance.

For $oRow In $oExcel.Worksheets("1").AutoFilter.Range.Rows
    If $oRow.Hidden = False Then
        _Excel_RangeCopyPaste($oExcel.ActiveSheet, $oRow(1).Columns(3), $oExcel.Worksheets("2").Range($Fi))
    EndIf
 Next

 

Share this post


Link to post
Share on other sites

You could simply delete the header range after you have copied all filtered  ranges. 


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2020-10-10 - Version 1.5.2.1) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2020-06-30 - Version 1.6.2.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (NEW 2020-06-27 - Version 1.3.2.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
Task Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki, WebDriver - Wiki

 

Share this post


Link to post
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

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...