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 Moderator Last seen December 27, 2022 - Nov 24, 2011 at 09:38 AM
TrowaD Posts 2921 Registration date Sunday September 12, 2010 Status Moderator Last seen December 27, 2022 - Nov 24, 2011 at 09:38 AM
Related:
- How to replace cell data based on criteria
- Tmobile data check - Guide
- Mint mobile data not working ✓ - Network Forum
- Transfer data from one excel worksheet to another automatically - Guide
- Transfer data from one excel worksheet to another automatically based on criteria ✓ - Excel Forum
- Gta 5 data download for pc - Download - Action and adventure
1 response
TrowaD
Posts
2921
Registration date
Sunday September 12, 2010
Status
Moderator
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