Change cell value if adjacent cell is not blank

chris_huh

New Member
Joined
Aug 4, 2011
Messages
26
I need cells C8:C15 to be set to "No" or blank if the adjacent cell in column B is either populated or empty, respectively.

I have:

Dim LR As Long, i As Long
LR = Range("B8:B15").Row
For i = 8 To LR
With Range("B" & i)
If Value = "" Then
.Offset(, 1).Value = ""
Else
.Offset(, 1).Value = "No"
End If
End With
Next i

but it doesn't work properly.

What have i done wrong?
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
Try

Code:
Dim LR As Long, i As Long
LR = Range("B" & rows.Count).End(xlUp).Row
For i = 8 To LR
    With Range("B" & i)
        If .Value = "" Then
            .Offset(, 1).Value = ""
        Else
            .Offset(, 1).Value = "No"
        End If
    End With
Next i
 
Upvote 0
It looked like that was working to start with, but i need it to only work on rows 8-15. I have other text in the lower down cells which can't be changed.
 
Upvote 0
Try

Code:
Dim i As Long
For i = 8 To 15
    With Range("B" & i)
        If .Value = "" Then
            .Offset(, 1).Value = ""
        Else
            .Offset(, 1).Value = "No"
        End If
    End With
Next i
 
Upvote 0

Forum statistics

Threads
1,224,521
Messages
6,179,282
Members
452,902
Latest member
Knuddeluff

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