Need to merge data logically
Closed
Mandy
-
Aug 16, 2014 at 11:18 AM
TrowaD Posts 2921 Registration date Sunday September 12, 2010 Status Moderator Last seen December 27, 2022 - Aug 18, 2014 at 11:40 AM
TrowaD Posts 2921 Registration date Sunday September 12, 2010 Status Moderator Last seen December 27, 2022 - Aug 18, 2014 at 11:40 AM
Related:
- Need to merge data logically
- Tmobile data check - Guide
- Transfer data from one excel worksheet to another automatically - Guide
- How to be offline in whatsapp when data is on - Guide
- How to reduce data usage on laptop windows 11 - Guide
- Data transmission cable - Guide
1 response
TrowaD
Posts
2921
Registration date
Sunday September 12, 2010
Status
Moderator
Last seen
December 27, 2022
552
Aug 18, 2014 at 11:40 AM
Aug 18, 2014 at 11:40 AM
Hi Mandy,
I'm missing some logic in the use of the F's and M's.
I thought whenever a new SUBACC is found, the OPBALTP should be "F" and the CLBALTP should be "M".
By this logic the CLBALTP of row 3 and 4 should be "F" and the final sample row the "F" and "M" should be switched.
If I'm correct and you are willing to sort your data first on SUBAAC and second on OPBALDT then the following code will work for you:
Best regards,
Trowa
I'm missing some logic in the use of the F's and M's.
I thought whenever a new SUBACC is found, the OPBALTP should be "F" and the CLBALTP should be "M".
By this logic the CLBALTP of row 3 and 4 should be "F" and the final sample row the "F" and "M" should be switched.
If I'm correct and you are willing to sort your data first on SUBAAC and second on OPBALDT then the following code will work for you:
Sub RunMe() Dim lRow As Long lRow = Range("A1").End(xlDown).Row Range("D2") = "F" Range("F2") = "M" For Each cell In Range("A3:A" & lRow) If cell.Value = cell.Offset(-1, 0).Value And _ cell.Offset(0, 2).Value <> cell.Offset(-1, 2).Value Then cell.Offset(0, 1).Value = cell.Offset(-1, 1) + 1 Else cell.Offset(0, 1).Value = cell.Offset(-1, 1) End If cell.Offset(0, 3).Value = "M" cell.Offset(0, 5).Value = "F" If cell.Value <> cell.Offset(-1, 0).Value Then cell.Offset(0, 3).Value = "F" cell.Offset(0, 5).Value = "M" cell.Offset(0, 1).Value = 1 End If Next cell End Sub
Best regards,
Trowa