How to replace cell data based on criteria
Closed
                                    
                        Craig                    
                                    -
                            Nov 22, 2011 at 11:09 AM
                        
TrowaD Posts 2921 Registration date Sunday September 12, 2010 Status Contributor Last seen December 27, 2022 - Nov 24, 2011 at 09:38 AM
        TrowaD Posts 2921 Registration date Sunday September 12, 2010 Status Contributor Last seen December 27, 2022 - Nov 24, 2011 at 09:38 AM
        Related:         
- How to replace cell data based on criteria
 - Mint mobile data not working ✓ - Network Forum
 - Tmobile data check - Guide
 - If cell contains (multiple text criteria) then return (corresponding text criteria) ✓ - Excel Forum
 - Based on the values in cells b77 b88 - Excel Forum
 - How to insert rows in excel automatically based on cell value without vba ✓ - Excel Forum
 
1 response
                
        
                    TrowaD
    
        
                    Posts
            
                
            2921
                
                            Registration date
            Sunday September 12, 2010
                            Status
            Contributor
                            Last seen
            December 27, 2022
            
            
                    555
    
    
                    
Nov 24, 2011 at 09:38 AM
    Nov 24, 2011 at 09:38 AM
                        
                    Hi Craig,
See if this code yields the desired result:
Best regards,
Trowa
            See if this code yields the desired result:
Sub test()
Dim lRow, lRow2, x, y As Integer
lRow = Sheets("Sheet1").Range("E" & Rows.Count).End(xlUp).Row
lRow2 = Sheets("Sheet2").Range("B" & Rows.Count).End(xlUp).Row
For Each cell In Sheets("Sheet1").Range("E1:E" & lRow)
x = 1
y = 0
Do
If cell.Value = Sheets("Sheet2").Cells(x, 2).Value Then
Sheets("Sheet2").Cells(x, 1).Copy Destination:=cell.Offset(0, -1)
y = y + 1
End If
x = x + 1
Loop Until x > lRow2
If y = 0 Then cell.EntireRow.Hidden = True
Next
End Sub
Best regards,
Trowa