Sign in to follow this  
Followers 0
ojef1

Excel Get Row

3 posts in this topic

Is there such a thing? I want to store the row number of whatever cell i happen to be in. This is kind of the idea, unfortunately "Activecell.Row" is a VBA command, not autoit.

To make it simpler, I could even write the row numbers 1-whatever into a column...but even then I can't figure out how to extract that into an autoit variable.

#include <Excel.au3>

AutoItSetOption("SendKeyDelay", 500)

$oExcel = _ExcelBookNew()
Send("^g")      ;go to cell
Send("e4")      ;random cell selection
Send("{ENTER}")
$Row = $oExcel.Worksheets(1).Activecell.Row     ;would like this to equal 4 (or whatever row it happens to be)
ConsoleWrite("Row: " & $Row "{ENTER}")

Share this post


Link to post
Share on other sites



If you're strictly looking for just the row of the selected cell...

$sRC= $oExcel.ActiveCell.Address                
$aRow = StringRegExp($sRC, "\$\w*\$(\d*)", 3)
$iRow = $row[0]

It's not the best way to go, there are other better ways to write it up but you get the idea. You can also have the .Address method return a different style of address, it's in the MSDN documentation.

Share this post


Link to post
Share on other sites

ActiveCell applies to the application object, try:

$Row = $oExcel.Application.Activecell.Row

:)


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

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
Sign in to follow this  
Followers 0