Selecting, coloring and defining a range

ChuckDrago

Active Member
Joined
Sep 7, 2007
Messages
470
Office Version
  1. 2010
Platform
  1. Windows
Hi everyone,

For an app under development, I need the user to:
1) Select a range of rows within a single column (say, A5:A15)
2) Color the background of the selected range.
3) Click on a button that opens a UserForm where the selected range is shown ( e.g. within a text box in the UDF, labeled Selected Range:) as "A5:A15" and its new color kept.

The active macro would then merge the cells within the range, write a certain label on it and save the workbook. Further workbook openings will show the range with the written words within and the color background changed.

In researching the web, I came across to this snippet:
<code>
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
With Target
.Worksheet.Cells.FormatConditions.Delete
.FormatConditions.Add xlExpression, , "TRUE"
.FormatConditions(1).Interior.Color = vbYellow
End With
End Sub
</code>
The only thing this allows is to change the color, but it retains neither the selected range color nor its address when clicking the button calling the active macro.

I will appreciate immensely if a modification to above or an alternative code is suggested to attain the sequence of events mentioned above.
Thanks, as usual
Chuck
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.

Forum statistics

Threads
1,213,529
Messages
6,114,155
Members
448,554
Latest member
Gleisner2

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