Quantcast
Channel: Active questions tagged excel - Stack Overflow
Viewing all articles
Browse latest Browse all 90251

Looping VBA code to check for highlighted cells

$
0
0

I would like a code to check every cell in range A1:A14 and if the cell is highlighted say yes or no in column B. As shown here.

Sub highlighted()

 Dim rng As Range
 Dim c As Range

    Set rng = ActiveCell

    For Each c In rng

      If c.Interior.Pattern <> xlNone Then

        ActiveCell.Offset(0, 1).Range("A1").Select
        ActiveCell.FormulaR1C1 = "Yes"

    Exit Sub

    End If

  Next c

End Sub

This code works sucsessfully for one single highlighted cell, how can I get it to loop through my desired range, and also include the "no" for non-highlighted cells?

Thanks In Advance!


Viewing all articles
Browse latest Browse all 90251


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>