Need to merge data logically
Closed
                                    
                        Mandy                    
                                    -
                            Aug 16, 2014 at 11:18 AM
                        
TrowaD Posts 2921 Registration date Sunday September 12, 2010 Status Contributor Last seen December 27, 2022 - Aug 18, 2014 at 11:40 AM
        TrowaD Posts 2921 Registration date Sunday September 12, 2010 Status Contributor Last seen December 27, 2022 - Aug 18, 2014 at 11:40 AM
        Related:         
- Need to merge data logically
- Merge twitter accounts - Guide
- Tmobile data check - Guide
- Data transmission cable - Guide
- Download facebook data - Guide
- Can you merge instagram accounts ✓ - Instagram Forum
1 response
                
        
                    TrowaD
    
        
                    Posts
            
                
            2921
                
                            Registration date
            Sunday September 12, 2010
                            Status
            Contributor
                            Last seen
            December 27, 2022
            
            
                    555
    
    
                    
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
