Jump to content

Getting the positions from multi-selected Cells


SeF
 Share

Recommended Posts

Hello!

I will try to explain what I want by giving an example.

First, a sample code:

HotKeySet("{F1}", "Start")

While 1
    sleep(100)
WEnd

Func Start()
    $oExcel = ObjGet("", "Excel.Application")
    $Positions = $oExcel.Application.Selection.Address
    MsgBox(0, "Example", $Positions)
EndFunc

See this Excel sheet:

Posted Image

If I select the cells like the picture and press "F1", the text on the MessageBox will be: $A$3:$A$7

But, If I apply some Filters like these:

Posted Image

The result will be the same: $A$3:$A$7

End of story: I get the same result with or without Filters.

I want to get every position from all the selected Cell (Actually, I need only the Rows...)

For example : pressing "F1" and returning only A3, A5 and A7 when the Filter is ON.

Thanks! :D

Edited by SeF
Link to comment
Share on other sites

Try something like:

#include <Excel.au3>

Global Const $xlCellTypeVisible = 12

; ...

$oSelRange = $oExcel.ActiveSheet.AutoFilter.Range.SpecialCells($xlCellTypeVisible)

Don't have Excel here to test.

:D

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Try something like:

#include <Excel.au3>

Global Const $xlCellTypeVisible = 12

; ...

$oSelRange = $oExcel.ActiveSheet.AutoFilter.Range.SpecialCells($xlCellTypeVisible)

Don't have Excel here to test.

:D

Thanks for the reply! :huggles:

I did it! Just by changing a little bit your code:

$Positions = $oExcel.Selection.SpecialCells($xlCellTypeVisible).Address
Edited by SeF
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...