View Single Post
 
Old 02-27-2019, 10:15 PM
Buzoka Buzoka is offline Windows 10 Office 2016
Novice
 
Join Date: Feb 2019
Posts: 2
Buzoka is on a distinguished road
Default Merge records split between two rows into single row

I am trying to create VBA code that will allow a user select a range of data and recombine records split between two lines into a single line and remove the blank lines. See attached images of the data Before and what is expected after processing.

Below is code i tried

Code:
Sub GetRowData()
    Dim Myrange As Range
    Dim Myrow As Range
    Set Myrange = Selection
    Dim strVal As String
    Dim sHold As String
    
    For Each Myrow In Myrange.Rows
    If Myrow.Row Mod 2 = 0 Then
    strVal = Myrow.Columns(1).Cells
    Myrow.Columns(1).Value = ""
    'MsgBox Myrow.Offset(1, -1).Address
    'Myrow.Offset(1, -1).Cells = strVal
    ActiveCell.Offset(1, -1).Value = strVal
    End If
    Next Myrow
End Sub
Attached Images
File Type: png Before.PNG (10.0 KB, 17 views)
File Type: png After.PNG (9.7 KB, 17 views)

Last edited by Pecoflyer; 02-28-2019 at 12:31 AM. Reason: Added code tags
Reply With Quote