Click here to Skip to main content
15,558,795 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello everyone! This must be quite easy, but I have been struggling for a while now (and yes, I googled but could not make sense of what I found).

My procedure receives an excel workbook as input parameter. I need to find the currently selected cell range...

My only line of code so far

xlWorksheet = xlInputWorkBook.ActiveSheet

Does anyone have a clue as how to i retrieve the selected cell range?

My guess is xlWorksheet.Cells.SomePropertyICanNotFind

TIA for your help!

PS: I am not using VBA, but VB.NET to build a standalone application
Updated 13-Oct-11 11:10am

1 solution

What you are looking for is actually just what you would expect... and that is Selection[^]

In it is a property of Application. This is because Excel is single user and therefor can have only one selection at a time.[^]

Good luck!
Share this answer
iris.frigole 14-Oct-11 11:02am    
Thanks! I think I stubbornly googled "excel worksheet" and "excel workbook" then selection, current range, active range and so on...

The thing is the Selection property "Returns the selected object in the active window." and, yes, even if one application has more than one workbook open it still has only one active window!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900