if values in Column D matches then

GirishDhruva

Active Member
Joined
Mar 26, 2019
Messages
308
Hi everyone,
I had created same thread https://www.mrexcel.com/forum/excel-questions/1098491-if-values-column-d-matches-then.html but as i couldn't view that thread i have created this.

Here i am trying to check the values in column 'D' and if the values in column 'D' matches then in column B it should print the value '60' else it should print '10'.


Like

[TABLE="width: 500"]
<tbody>[TR]
[TD]Column A[/TD]
[TD]Column B[/TD]
[TD]Column D[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]60[/TD]
[TD]4359[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]10[/TD]
[TD]45132[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]10[/TD]
[TD]'4324[/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]10[/TD]
[TD]1324[/TD]
[/TR]
[TR]
[TD]5[/TD]
[TD]10[/TD]
[TD]5123[/TD]
[/TR]
[TR]
[TD]6[/TD]
[TD]60[/TD]
[TD]'4359[/TD]
[/TR]
[TR]
[TD]7[/TD]
[TD]10[/TD]
[TD]06471[/TD]
[/TR]
[TR]
[TD]8[/TD]
[TD]10[/TD]
[TD]12345[/TD]
[/TR]
[TR]
[TD]9[/TD]
[TD]60[/TD]
[TD]'4359[/TD]
[/TR]
[TR]
[TD]10[/TD]
[TD]10[/TD]
[TD]53121[/TD]
[/TR]
[TR]
[TD]11[/TD]
[TD]60[/TD]
[TD]4359[/TD]
[/TR]
[TR]
[TD]12[/TD]
[TD]10[/TD]
[TD]'5123[/TD]
[/TR]
[TR]
[TD]13[/TD]
[TD]10[/TD]
[TD]512323[/TD]
[/TR]
[TR]
[TD]14[/TD]
[TD]60[/TD]
[TD]4359[/TD]
[/TR]
</tbody>[/TABLE]

The values in column 'D' can also be text

Thanks in advance
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
Hi Everyone,
I am not very much good in coding but i am trying below code as it's throwing me an error in highlighted, can i know why????
Rich (BB code):
lrow = Cells(Rows.Count, "D").End(xlUp).Row
For i = 4 To lrow
    If Cells(i, 1).Value = "4359" Then
        Range(Cells(Rows(i), "B")).Value = "60"
    Else
        Range(Cells(Rows(i), "B")).Value = "10"
    End If
Next i
 
Last edited:
Upvote 0
Try this:
Code:
Sub My_Sub()
'Modified  5/22/2019  2:01:01 AM  EDT
lrow = Cells(Rows.Count, "D").End(xlUp).Row
For i = 4 To lrow
    If Cells(i, "D").Value = "4359" Then
        Cells(i, "B").Value = "60"
    Else
        Cells(i, "B").Value = "10"
    End If
Next i
End Sub
 
Upvote 0
Glad I was able to help. But in your original post you said:

Here i am trying to check the values in column 'D' and if the values in column 'D' matches

But you did not say matches "4359"

There are numerous different values in column D

I would think in this case you would have said matches "4359"
 
Upvote 0
Glad I was able to help. But in your original post you said:

Here i am trying to check the values in column 'D' and if the values in column 'D' matches

But you did not say matches "4359"

There are numerous different values in column D

I would think in this case you would have said matches "4359"

Ya i think i have confused , sorry for that
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,170
Members
453,021
Latest member
Justyna P

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