If Statement Copied Down Row

PhancyK

New Member
Joined
Jan 17, 2016
Messages
46
Hey all,

Seems easy but I can't quite get it all together. I'm looking for a way to have this vba used in row J only if there is text in row B.

Sub Test1()
If (Range("I6").Value = Range("I2").Value Then
Range("J6").Value = "Y"
End If
End Sub

Basically having 2 cells (I6 and I2) checked if they are the same and returning a Y (to J6) if they are equal.

I6 and J6 move down as it goes but I2 will always stay the same.

Any thoughts?
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
What does this mean?
I6 and J6 move down as it goes but I2 will always stay the same.

Moves down to where.

Are you saying you always want to just check I6 and I2 ??

And you understand I6 means Column I row 6?
 
Upvote 0
Sorry it's late and I've been staring at this screen for too long.

I want to check starting with cell I6 against cell I2, and then I7 against I2, then I8, I9, and down... but only for rows that have text in column B.

If those 2 cells are equal then it would put a "Y" in the column next to it, so in J6, J7, J8 etc... If they are different then it would be blank.
 
Upvote 0
So this script continues as long as there are values in column B

It looks down column J to see if the value in column J is the same as the value in Range("I2")
If the value in column J is the same as the value in Range("I2") a Y is placed in column J

This all starts in Row 6 Of column I

Try this:

Code:
Sub Check_Me()
'Modified  11/13/2018  12:53:01 AM  EST
Application.ScreenUpdating = False
Dim i As Long
Dim Lastrow As Long
Dim ans As String
ans = Range("I2").Value
Lastrow = Cells(Rows.Count, "B").End(xlUp).Row
    For i = 6 To Lastrow
        If Cells(i, 9).Value = ans Then Cells(i, 10).Value = "Y"
    Next
Application.ScreenUpdating = True
End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,889
Messages
6,175,224
Members
452,620
Latest member
dsubash

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