0

I'm trying to highlight a row that's assigned to "RowNum" I want to highlight Columns A through O. I've tried the things below, But receive syntax errors on each.

sh1.Cells(RowNum, 15).Interior.Color = RGB(127, 187, 199)
sh1.Range("A" & RowNum : "O" & RowNum).interior.color = rgb (127,187,199)

In the past, I've used this to highlight a set range or individual cells.

sh1.Range("W1:X1").Interior.Color = RGB(252, 213, 180)

I know I've done this in the past, either that or I am suffering a concussion.

3
  • "But neither are working correctly" isn't a good description, what is the issue exactly? Have you tried recording a similar macro, does it work? Jul 19, 2016 at 19:03
  • I receive syntax errors on both lines.(thanks for pointing that out, making edit now) The macro recorder won't work because I am trying to use a variable for the row number. Jul 19, 2016 at 19:05
  • We need more information if you want us to help. Please post the syntax you have tried (we have this) and directly below it please post what the error you receive is. From the limited information in your post, one would think you googled to find the code snippets above and are attempting to use SO as a code writing service. Jul 19, 2016 at 19:40

1 Answer 1

1

If sh1.Range("A" & RowNum : "O" & RowNum).interior.color = rgb (127,187,199) is the actual line from your macro, you have a typo

sh1.Range("A" & RowNum : "O" & RowNum) should be sh1.Range("A" & RowNum & ":" & "O" & RowNum)

The colon : needs to be concatenated like everything else, since it's part of the range string

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .