Highlight Selected Cells

vbabeginner92

New Member
Joined
Jul 25, 2018
Messages
13
I am trying to create a macro that will highlight cells already selected. Below is the code I used but that is only working for the active cell. How can I alter the code to highlight all the cells I selected.

Example: Cell C15 is the active cell and cells C15:C20 are selected. When I run my macro, only C15 is highlighted, but I want cells C15:C20 highlighted.

Sub Highlighter()
ActiveCell.Interior.Color = RGB (255,255,0)
End Sub
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
31,907
Office Version
365
Platform
Windows
Replace ActiveCell with Selection
 

Jack in the UK

Well-known Member
Joined
Feb 16, 2002
Messages
3,215
Code:
Sub Highlightx()
Dim myRange As Excel.Range
Set myRange = Range("C15:C20")

myRange.Interior.Color = RGB(255, 255, 0)

End Sub
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
31,907
Office Version
365
Platform
Windows
Glad we could help & thanks for the feedback
 

Jack in the UK

Well-known Member
Joined
Feb 16, 2002
Messages
3,215
All good thanks for posting back... open a test workbook and havea play and have some fun. Post in a new thread if you have any other questios

jiuk
 

Forum statistics

Threads
1,081,415
Messages
5,358,533
Members
400,502
Latest member
price83

Some videos you may like

This Week's Hot Topics

  • VBA (Userform)
    Hi All, I just would like to know why my code isn't working. Here is my VBA code: [CODE=vba]Private Sub OKButton_Click() Dim i As Integer...
  • List box that changes fill color
    Hello, I have gone through so many pages trying to figure this out. I have a 2020 calendar that depending on the day needs to have a certain...
  • Remove duplicates and retain one. Cross-linked cases
    Hi all I ran out of google keywords to use and still couldn't find a reference how to achieve the results of a single count. It would be great if...
  • VBA Copy and Paste With Duplicates
    Hello All, I'm in need of some input. My VBA skills are sub-par at best. I've assembled this code from basic research and it works but is...
  • Macro
    is it possible for a macro to run if the active cell value is different to the value above it
  • IF DATE and TIME
    I currently use this to check if date has passed but i also need to set a time on it too. Is it possible? [CODE=vba]=IF(B:B>TODAY(),"Not...
Top