Question : excel macro find selected range to use within macro

Hi,

I need to be able to find the range of the selection for my macro. How can i do this?

the idea is, it will only print out something with the rows that are selected.

thx

Answer : excel macro find selected range to use within macro

You can put the following code in the macro that gets run when the user hits the button

Dim rngSelection as Range
Dim rngRow as Range

set rngSelection = Selection       'this will provide you with the range (rows) that the user has selected
For each rngRow in rngSelection.Entirerow
   'in this loop rngRow will give you each row that the user had selected. you can print it out or loop through each cell of the row.
next

hope this helps.
Random Solutions  
 
programming4us programming4us