Need to merge data logically
Closed
Mandy
-
16 Aug 2014 à 11:18
TrowaD Posts 2921 Registration date Sunday 12 September 2010 Status Contributor Last seen 27 December 2022 - 18 Aug 2014 à 11:40
TrowaD Posts 2921 Registration date Sunday 12 September 2010 Status Contributor Last seen 27 December 2022 - 18 Aug 2014 à 11:40
Related:
- Need to merge data logically
- Merge twitter accounts - Guide
- How to copy data from one excel sheet to another - Guide
- Tmobile data check - Guide
- Copying data from one Excel sheet to another. ✓ - Excel Forum
- What term is used to describe a logical drive that can be formatted to store data? - Guide
1 response
TrowaD
Posts
2921
Registration date
Sunday 12 September 2010
Status
Contributor
Last seen
27 December 2022
555
18 Aug 2014 à 11:40
18 Aug 2014 à 11:40
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