Skip a value

[Closed]
Report
Posts
1
Registration date
Tuesday November 19, 2013
Status
Member
Last seen
November 19, 2013
-
Posts
2805
Registration date
Sunday September 12, 2010
Status
Moderator
Last seen
September 14, 2021
-
suppose a1 a2 a3 = john,michel, robert, respectively and b1,b2,b3=10,9,10 then from values of b cell i wanted to print name in g cell who have corresponding values in b 10 only . i don't want to print name corresponding to 9. my problem is that the blank cell appears between g1 and g3............. so i want g3 value in g2............ please help me out.

1 reply

Posts
2805
Registration date
Sunday September 12, 2010
Status
Moderator
Last seen
September 14, 2021
482
Hi Prabinkaal,

I would advise you to use a header and then use the following code for best result:
Sub RunMe()
Dim lRow As Integer
lRow = Range("B1").End(xlDown).Row
For Each cell In Range("B2:B" & lRow)
If cell = 10 Then cell.Offset(0, -1).Copy _
Range("G" & Rows.Count).End(xlUp).Offset(1, 0)
Next cell
End Sub

Best regards,
Trowa