Kaarl Posted July 17, 2018 Share Posted July 17, 2018 Hi, I have an Excel file that contains specific named range in a specific sheet. I can read the content of the range using: Local $RangeContent = _Excel_RangeRead($oWorkbook, "MySheetName", "MyRangeName") The position of the range within the sheet can vary. I need to find out the position of the range (like B25 or C5 or wherever it is) so that I can pass it to other functions. So I would need something like this: Local $MyRangeColumn = _GET_THE_COLUMN($oWorkbook, "MySheetName", "MyRangeName") Local $MyRangeRow = _GET_THE_ROW($oWorkbook, "MySheetName", "MyRangeName") The range always contains only one cell (like A1), it is never larger (like A1:B3). The problem may be that the sheet is hidden so I can't .Activate it (but the _Excel_RangeRead still works). I was searching through the forums but I could't find anything useful, and I'm not even sure how to start. Any help is appreciated. Thanks, Kaarl Link to comment Share on other sites More sharing options...
Moonscarlet Posted July 17, 2018 Share Posted July 17, 2018 (edited) Hi, See https://www.autoitscript.com/autoit3/docs/libfunctions/_Excel_RangeFind.htm Edit: I may have misunderstood, do you want to get the row/col name of a range or look for the range that contains something? $Row= $oWorkbook.Sheets("SHEETNAME").Range("A1").Row) $Column= _Excel_ColumnToLetter($oWorkbook.Sheets("SHEETNAME").Range("A1").Column)) Edited July 17, 2018 by Moonscarlet Link to comment Share on other sites More sharing options...
Kaarl Posted July 17, 2018 Author Share Posted July 17, 2018 I need to get the row number (1, 3, 5 or whatever) and column name (A, C, BX or whatever). So if the named range is situated in cell B3 I need to get something like. $MyRangeColumn = "B" $MyRangeRow = 3 It doesn't really matter now whether the range has any content in it or not. Important are its coordinates, because they determine locations of other data in the sheet. My named range can be a location of a header of a column or name of a row, so I need the coordinates to read the data in the appropriate column/row. I hope this clarifies it better. Link to comment Share on other sites More sharing options...
Moonscarlet Posted July 17, 2018 Share Posted July 17, 2018 I see, here it is again, as I edited my previous post: $Row= $oWorkbook.Sheets("SHEETNAME").Range("A1").Row) $Column= _Excel_ColumnToLetter($oWorkbook.Sheets("SHEETNAME").Range("A1").Column)) Kaarl 1 Link to comment Share on other sites More sharing options...
Kaarl Posted July 17, 2018 Author Share Posted July 17, 2018 I've got still a lot to learn. Works like a charm (except the extra brackets at end that throw a syntax error). This one works: $Row= $oWorkbook.Sheets("SHEETNAME").Range("A1").Row $Column= _Excel_ColumnToLetter($oWorkbook.Sheets("SHEETNAME").Range("A1").Column) Thanks a lot for the solution! Link to comment Share on other sites More sharing options...
Moonscarlet Posted July 17, 2018 Share Posted July 17, 2018 Yes, sorry about that, forgot to remove it as I was using it in a MsgBox() Kaarl 1 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now