Macro: Turning a Select Row into a Select Cell

Unimatic1140

New Member
Joined
Jul 18, 2002
Messages
27
Hello, my macro starts out with a variable amount rows selected by the user. Near the end of the macros execution I need to deselect the entire rows and select just the cells in column C of the rows selected originally. For example lets say the users start the macro with Rows 9:14 selected. At the end I need the macro to automatically select cells C9:C14. Does anyone know how I can convert the selected value of the Rows into a cell range?

Thanks in advances for everyone’s help.
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
Something like this will do it:

<pre>
Public Sub main()
'Declare Variable
Dim oRange As Range
'Set oRange = to the selected Range
Set oRange = Selection


'Put the rest of your code here
' blah de blah etc etc


'Then to select the column C range
With oRange
Range(Cells(.Cells(1).Row, 3), Cells(.Cells(.Count).Row, 3)).Select
End With

End Sub</pre>

It's maybe not the most elegant way to do it, but it will work.

HTH
 
Upvote 0

Forum statistics

Threads
1,218,541
Messages
6,143,102
Members
450,463
Latest member
DaveG999

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top