how to use range and calculate offset

Danny54

Active Member
Joined
Jul 3, 2019
Messages
295
Office Version
  1. 365
Platform
  1. Windows
1582318483044.png


I have the following code :
Sub checkit()
Dim c As Range
Dim z1 As Integer
Dim LastRow As Integer

With Worksheets(1).Range("A1:O100")
z1 = 0
LastRow = UsedRange.Rows.Count

For Each c In Range(.Cells(2, 9), .Cells(LastRow, 11))
If c.Interior.Color = RGB(255, 255, 0) Then
If ActiveCell.Offset(0, 7).Value = "Yes" Then
z1 = z1 + 1
End If
End If
Next c
End With
MsgBox z1
End Sub

so, if yellow found in any of the columns I thru K and "Yes" is found in column P add 1 to a counter and do same look in the next row thru the lastRow.

the above example would show 2 when done.

my problem is how to get this to work.
If ActiveCell.Offset(0, 7).Value = "Yes" Then


Thanks
 

Attachments

  • 1582318551530.png
    1582318551530.png
    20.3 KB · Views: 4

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
How about
VBA Code:
If Range("P"&c.row).Value = "Yes" Then
 
Upvote 0
wow,
thanks so much. It worked perfectly. Sometimes you get to close to the problem and can't see the resolution.

Have a Great Weekend!
 
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,214,644
Messages
6,120,709
Members
448,983
Latest member
Joaquim_Baptista

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