Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 02-27-2019, 10:15 PM
Buzoka Buzoka is offline Merge records split between two rows into single row Windows 10 Merge records split between two rows into single row Office 2016
Novice
Merge records split between two rows into single row
 
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, 15 views)
File Type: png After.PNG (9.7 KB, 15 views)

Last edited by Pecoflyer; 02-28-2019 at 12:31 AM. Reason: Added code tags
Reply With Quote
  #2  
Old 02-28-2019, 12:10 AM
xor xor is offline Merge records split between two rows into single row Windows 10 Merge records split between two rows into single row Office 2016
Expert
 
Join Date: Oct 2015
Posts: 1,097
xor is a name known to allxor is a name known to allxor is a name known to allxor is a name known to allxor is a name known to allxor is a name known to all
Default

Can't you just use formulas?
Attached Files
File Type: xlsx Rearrange.xlsx (24.2 KB, 9 views)
Reply With Quote
  #3  
Old 02-28-2019, 12:31 AM
Pecoflyer's Avatar
Pecoflyer Pecoflyer is offline Merge records split between two rows into single row Windows 7 64bit Merge records split between two rows into single row Office 2010 64bit
Expert
 
Join Date: Nov 2011
Location: Brussels Belgium
Posts: 2,770
Pecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant future
Default

Hi and welcome
in the future, please wrap your code with code tags (the #button)
If you are after a VBA solution please post in the correct sub-forum ( I will move it for you)
Thanks


BTW posting a sheet is better than a picture, which is nice to look at but worthless to work on
__________________
Did you know you can thank someone who helped you? Click on the tiny scale in the right upper hand corner of your helper's post
Reply With Quote
  #4  
Old 02-28-2019, 06:52 AM
Buzoka Buzoka is offline Merge records split between two rows into single row Windows 10 Merge records split between two rows into single row Office 2016
Novice
Merge records split between two rows into single row
 
Join Date: Feb 2019
Posts: 2
Buzoka is on a distinguished road
Default

I need the solution applied to many workbooks and multiple records on each worksheet. I have to be able to select the range and apply the code over the selected range. Thanks
Reply With Quote
  #5  
Old 02-28-2019, 09:05 AM
NoSparks NoSparks is offline Merge records split between two rows into single row Windows 7 64bit Merge records split between two rows into single row Office 2010 64bit
Excel Hobbyist
 
Join Date: Nov 2013
Location: British Columbia, Canada
Posts: 831
NoSparks is just really niceNoSparks is just really niceNoSparks is just really niceNoSparks is just really niceNoSparks is just really nice
Default

Do you confine your selection to the column you want to work with ?
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Merge records split between two rows into single row Grouping multiple excel records in to a single letter lmjb1964 Mail Merge 4 04-04-2018 03:33 PM
Split sum of one single row FTL Excel 2 11-21-2017 12:54 AM
Merge records split between two rows into single row Merging multiple excel records in to a single word doc? dns_to Mail Merge 1 10-20-2017 01:22 PM
Merge records split between two rows into single row How do I mail merge records into table columns with more than one merge field? tech123 Mail Merge 1 04-26-2017 07:13 PM
Merge records split between two rows into single row How to combine several records in a single letter in Word 2010 May Mail Merge 3 03-25-2015 03:36 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 04:29 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft