aayaanmayank
Board Regular
- Joined
- Jul 20, 2018
- Messages
- 157
Hi Can some one help me with the code that if 80% Length matched then give green color else yellow color.
i have written below code however it is doing green color if 80% length has same string
e.g.
[TABLE="width: 216"]
<tbody>[TR]
[TD]GULFDRUGGU (Length 8)
GULFDRUGGULFDRUGESTABLISHMENT (Lenghth 21)
so it should through yellow color
Name[/TD]
[/TR]
[TR]
[TD]ALMAZROUIMEDICALICALCHEMICALSUPPLIES[/TD]
[/TR]
[TR]
[TD]ALMAZROUIMEDICALICALCHEMICALSUPPLIES[/TD]
[/TR]
[TR]
[TD]INTERNATIONALAERADIOEMI[/TD]
[/TR]
[TR]
[TD]INTERNATIONALAERADIOEMIRATE[/TD]
[/TR]
[TR]
[TD]GULFDRUG[/TD]
[/TR]
[TR]
[TD]GULFDRUGESTABLISHMENT[/TD]
[/TR]
</tbody>[/TABLE]
[TABLE="width: 216"]
<tbody>[TR]
[TD]INTERNATIONALAERADIOEMI[/TD]
[/TR]
[TR]
[TD]INTERNATIONALAERADIOEMIRATE[/TD]
[/TR]
</tbody>[/TABLE]
i have written below code however it is doing green color if 80% length has same string
e.g.
[TABLE="width: 216"]
<tbody>[TR]
[TD]GULFDRUGGU (Length 8)
GULFDRUGGULFDRUGESTABLISHMENT (Lenghth 21)
so it should through yellow color
Code:
Dim rng As Range, cel As RangeWith Worksheets("Grouping Data_Underwriters")
Set rng = .Range([F2], .Range("F" & Rows.Count).End(xlUp))
End With
For Each cel In rng
If Left(cel, Len(cel) * 0.8) = Left(cel(2), Len(Left(cel, Len(cel) * 0.8))) Then _
cel.Resize(2).Interior.Color = vbGreen
Next
[/TR]
[TR]
[TD]ALMAZROUIMEDICALICALCHEMICALSUPPLIES[/TD]
[/TR]
[TR]
[TD]ALMAZROUIMEDICALICALCHEMICALSUPPLIES[/TD]
[/TR]
[TR]
[TD]INTERNATIONALAERADIOEMI[/TD]
[/TR]
[TR]
[TD]INTERNATIONALAERADIOEMIRATE[/TD]
[/TR]
[TR]
[TD]GULFDRUG[/TD]
[/TR]
[TR]
[TD]GULFDRUGESTABLISHMENT[/TD]
[/TR]
</tbody>[/TABLE]
[TABLE="width: 216"]
<tbody>[TR]
[TD]INTERNATIONALAERADIOEMI[/TD]
[/TR]
[TR]
[TD]INTERNATIONALAERADIOEMIRATE[/TD]
[/TR]
</tbody>[/TABLE]
Last edited: