Can anyone direct me on what code I can put behind a button so that once I click on that button,
What ever cell i click on, the whole row of that cell will be colored a certain color.
Is this where i would used a target approach?
Can anyone direct me on what code I can put behind a button so that once I click on that button,
What ever cell i click on, the whole row of that cell will be colored a certain color.
Is this where i would used a target approach?
It can be done by selecting cell first and than click the button
![]()
Sub Button1_click() ActiveSheet.Rows(ActiveCell.Row).Interior.Color = RGB(255, 0, 0) End Sub
try this:
See here for list of colorindex![]()
Sub cmd() ActiveCell.EntireRow.Interior.ColorIndex = 3 End Sub
http://www.databison.com/excel-color...nge-using-vba/
Alan עַם יִשְׂרָאֵל חַי
Change an Ugly Report with Power Query
Database Normalization
Complete Guide to Power Query
Man's Mind Stretched to New Dimensions Never Returns to Its Original Form
what if i want to do just certain set of continuous columns for example A-J
How would I write the code to specify that target range?
Try this.. this code will work without a button.. put the code in the sheet module..
![]()
Private Sub Worksheet_SelectionChange(ByVal Target As Range) Dim Low As Double Dim High As Double Low = 26 '< change as desired High = 47 '< change as desired 'If the target cell is clear If Target.EntireRow.Interior.ColorIndex = xlNone Then 'Then change the background to a random color Target.EntireRow.Interior.ColorIndex = Int((High - Low + 1) * Rnd() + Low) 'But if the target cell is already the color ElseIf Target.EntireRow.Interior.ColorIndex <> xlNone Then 'Then clear the background color Target.EntireRow.Interior.ColorIndex = xlNone End If End Sub
Sweeet thanks guys
If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks