Combine two columns into one by inserting a row.

%3CLINGO-SUB%20id%3D%22lingo-sub-1543360%22%20slang%3D%22en-US%22%3ECombine%20two%20columns%20into%20one%20by%20inserting%20a%20row.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1543360%22%20slang%3D%22en-US%22%3E%3CP%3EHi%2C%20I%20am%20trying%20to%20combine%20two%20columns%20into%20one.%20Column%20F%20has%20the%20product%20sold%20and%20column%20G%20has%20the%20postage.%20I%20would%20like%20to%20know%20if%20it%20is%20possible%20for%20the%20amount%20from%20column%20G%20to%20be%20moved%20to%20column%20F%20by%20inserting%20a%20row%20in%20column%20F%20for%20it%20to%20be%20moved%20to%20that%20is%20not%20a%20manual%20process%20but%20a%20function%20or%20macro%20that%20can%20be%20set%20up.%3C%2FP%3E%3CP%3EHope%20that%20makes%20sense.%3C%2FP%3E%3CP%3EThanks%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1543360%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EFormulas%20and%20Functions%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EMacros%20and%20VBA%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1543393%22%20slang%3D%22en-US%22%3ERe%3A%20Combine%20two%20columns%20into%20one%20by%20inserting%20a%20row.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1543393%22%20slang%3D%22en-US%22%3EThat%20would%20be%20the%20easiest%20way%20to%20do%20it%2C%20of%20course%20it%20can%20also%20be%20done%20with%20VBA%20...%20if%20there%20are%20a%20lot%20of%20rows%20%2F%20columns.%3CBR%20%2F%3E%3CBR%20%2F%3EF2%20G2%20H2%20Formula%20H2%3CBR%20%2F%3ETEST%20CAR%20TEST%20CAR%20%3DF2%26amp%3B%22%20%22%26amp%3BG2%3CBR%20%2F%3E%3CBR%20%2F%3EIf%20you%20liked%20the%20solution%2C%20please%20post%20it%20as%20a%20Best%20Responses%20with%20a%20like%20(press%20thumbs%20up).%20If%20you%20did%20not%20like%20the%20solution%2C%20please%20give%20me%20a%20little%20reply%20to%20find%20a%20more%20customized%20solution%20for%20you.%3CBR%20%2F%3E%3CBR%20%2F%3EI%20would%20be%20happy%20to%20find%20out%20if%20I%20could%20help.%3CBR%20%2F%3E%3CBR%20%2F%3ENikolino%3CBR%20%2F%3EI%20know%20I%20don't%20know%20anything%20(Socrates)%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1543405%22%20slang%3D%22en-US%22%3ERe%3A%20Combine%20two%20columns%20into%20one%20by%20inserting%20a%20row.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1543405%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F738753%22%20target%3D%22_blank%22%3E%40SueDuff%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EHere%20is%20a%20macro%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-applescript%22%3E%3CCODE%3ESub%20InsertAndMove()%0A%20%20%20%20Dim%20r%20As%20Long%0A%20%20%20%20Dim%20m%20As%20Long%0A%20%20%20%20Application.ScreenUpdating%20%3D%20False%0A%20%20%20%20m%20%3D%20Range(%22F%22%20%26amp%3B%20Rows.Count).End(xlUp).Row%0A%20%20%20%20For%20r%20%3D%20m%20To%202%20Step%20-1%0A%20%20%20%20%20%20%20%20Range(%22F%22%20%26amp%3B%20r%20%2B%201).Insert%20Shift%3A%3DxlShiftDown%0A%20%20%20%20%20%20%20%20Range(%22F%22%20%26amp%3B%20r%20%2B%201).Value%20%3D%20Range(%22G%22%20%26amp%3B%20r).Value%0A%20%20%20%20%20%20%20%20Range(%22G%22%20%26amp%3B%20r).Clear%0A%20%20%20%20Next%20r%0A%20%20%20%20Application.ScreenUpdating%20%3D%20True%0AEnd%20Sub%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIf%20you%20want%20to%20insert%20an%20entire%20row%20instead%20of%20only%20a%20cell%20in%20column%20G%2C%20change%20the%20line%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20Range(%22F%22%20%26amp%3B%20r%20%2B%201).Insert%20Shift%3A%3DxlShiftDown%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3Eto%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20Range(%22F%22%20%26amp%3B%20r%20%2B%201).EntireRow.Insert%20Shift%3A%3DxlShiftDown%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1543509%22%20slang%3D%22en-US%22%3ERe%3A%20Combine%20two%20columns%20into%20one%20by%20inserting%20a%20row.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1543509%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F738753%22%20target%3D%22_blank%22%3E%40SueDuff%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EYou%20wrote%3A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%3CEM%3E%20Hi%2C%20I%20am%20trying%20to%20combine%20two%20columns%20into%20one....I%20would%20like%20to%20know%20if%20it%20is%20possible%20for%20the%20amount%20from%20column%20G%20to%20be%20moved%20to%20column%20F%20by%20inserting%20a%20row%20in%20column%20F%20for%20it%20to%20be%20moved%20to%20that%20is%20not%20a%20manual%20process%20but%20a%20function%20or%20macro%20that%20can%20be%20set%20up.%3C%2FEM%3E%3C%2FP%3E%3CP%3E%3CSTRONG%3E%3CEM%3EHope%20that%20makes%20sense.%3C%2FEM%3E%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIt%20did%20make%20sense%2C%20in%20the%20sense%20that%20you%20were%20clear%20on%20what%20you%20wanted%20to%20do.%20And%20you've%20gotten%20two%20answers%20that%2C%20I'm%20assuming%2C%20make%20it%20possible.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThere's%20another%20way%20to%20%22making%20sense%22%20however....and%20my%20%22sense%20maker%22%20is%20wondering%20%22Why%3F%22%26nbsp%3B%20As%20in%20%22Why%20are%20you%20trying%20to%20do%20this%20in%20the%20first%20place%3F%22%26nbsp%3B%26nbsp%3B%20In%20general--and%20maybe%20your%20situation%20is%20an%20entirely%20legitimate%20exception--Excel%20does%20very%20well%20with%20information%20such%20as%20you're%20describing%20arrayed%20as%20an%20Excel%20Table%2C%20which%20is%20to%20say%2C%20one%20record%20per%20row.%20So%20such%20things%20as%20a%20record%20of%20a%20sale%20would%20be%20stored%20as%20a%20single%20row%2C%20arrayed%20perhaps%20as%3C%2FP%3E%3CP%3EDate.....SKU....ProdID...Quantity.....BuyerName...BuyerAddress....Postage.....%3C%2FP%3E%3CP%3EAnd%20from%20that%20kind%20of%20record%20you%20could%20do%20all%20kinds%20of%20things%20quite%20easily....reports%20on%20how%20many%20of%20each%20product%20were%20sold%20in%20a%20given%20month%2C%20how%20many%20were%20sold%20to%20buyers%20in%20NC....whatever.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIt's%20the%20very%20great%20ease%20of%20accomplishing%20almost%20anything%20from%20a%20database%20that%20holds%20each%20record%20as%20a%20single%20row%20that%20makes%20me%20wonder%20the%20%22Why%3F%22%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIf%20all%20you%20are%20doing%20is%20creating%20a%20report%20that%20shows%20summary%20numbers%20by%20Product%20of%20Postage%20costs%20to%20ship%2C%20that%20would%20be%20a%20report.....%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAnyway%2C%20if%20you%20could%20excuse%20the%20impertinence%20of%20my%20asking%2C%20I'd%20like%20to%20understand%20how%20it%20makes%20sense%20in%20this%20respect%3A%20%3CEM%3Ewhat%20was%20the%20purpose%3F%3C%2FEM%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CEM%3E(There%20might%20well%20have%20been%20an%20easier%20way%20to%20accomplish%20that%20purpose.)%3C%2FEM%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAs%20an%20aside%2C%20this%20is%20particularly%20interesting%20because%20within%20the%20last%20few%20hours%2C%20another%20user%20posted%20a%20question%20wanting%20to%20go%20in%20exactly%20the%20opposite%20direction....turning%20data%20in%20one%20column%20but%20two%20rows%2C%20into%20one%20row%2C%20two%20columns....%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fexcel%2Fsplit-a-column-by-rows%2Fm-p%2F1543283%22%20target%3D%22_blank%22%3Ehttps%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fexcel%2Fsplit-a-column-by-rows%2Fm-p%2F1543283%3C%2FA%3E%3C%2FP%3E%3CP%3EThat%20other%20request%20makes%20more%20sense%20from%20a%20database%20(or%20Excel%20Table)%20point%20of%20view...%20in%20that%20case%2C%20my%20question%20would%20have%20been%20%22Why%20was%20it%20in%20that%20other%20layout%20in%20the%20first%20place%3F%22%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1543676%22%20slang%3D%22en-US%22%3ERe%3A%20Combine%20two%20columns%20into%20one%20by%20inserting%20a%20row.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1543676%22%20slang%3D%22en-US%22%3EThanks%20for%20the%20advice.%20I%20am%20looking%20to%20create%20a%20CSV%20file%20that%20can%20be%20upload%20to%20an%20accounting%20package%20and%20it%20is%20very%20specific%20about%20the%20layout%20or%20it%20rejects%20it.%20The%20files%20I%20download%20have%20all%20the%20information%20I%20need%20but%20in%20the%20wrong%20places%20(multiple%20columns)%20as%20I%20need%20certain%20information%20in%20one%20column%2C%20linked%20to%20a%20name%20and%20order%20number%20arranged%20in%20rows%20rather%20than%20columns.%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1543686%22%20slang%3D%22en-US%22%3ERe%3A%20Combine%20two%20columns%20into%20one%20by%20inserting%20a%20row.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1543686%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F127945%22%20target%3D%22_blank%22%3E%40Hans%20Vogelaar%3C%2FA%3E%26nbsp%3BI%20will%20give%20it%20a%20try%2C%20thank%20you.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1543790%22%20slang%3D%22en-US%22%3ERe%3A%20Combine%20two%20columns%20into%20one%20by%20inserting%20a%20row.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1543790%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F738753%22%20target%3D%22_blank%22%3E%40SueDuff%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EYou%20very%20nicely%20replied%20to%20my%20impertinent%20question%20of%20%22Why%3F!%22%3A%20%3CEM%3EI%20am%20looking%20to%20create%20a%20CSV%20file%20that%20can%20be%20upload%20to%20an%20accounting%20package%20and%20it%20is%20very%20specific%20about%20the%20layout%20or%20it%20rejects%20it.%20The%20files%20I%20download%20have%20all%20the%20information%20I%20need%20but%20in%20the%20wrong%20places%20(multiple%20columns)%20as%20I%20need%20certain%20information%20in%20one%20column%2C%20linked%20to%20a%20name%20and%20order%20number%20arranged%20in%20rows%20rather%20than%20columns.%3C%2FEM%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSTRONG%3EFirst%3C%2FSTRONG%3E%2C%20thank%20you%20for%20explaining%20the%20purpose%20you%20were%20seeking%20to%20serve.%3C%2FP%3E%3CP%3E%3CSTRONG%3ESecond%3C%2FSTRONG%3E%2C%20your%20answer%2C%20I%20must%20say%2C%20surprises%20me.%20If%20only%20for%20this%20reason%3A%20when%20I%20get%20CSV%20files%20from%20various%20financial%20sources--Fidelity%2C%20Chase%2C%20Citibank%2C%20AmEx--they%20all%20are%20arrayed%20with%20records%20in%20rows%2C%20not%20columns.%20I.e.%2C%20in%20what%20I'd%20call%20standard%20database%20fashion.%20So%20it%20is%20surprising%20to%20hear%20that%20this%20accounting%20package%20is%20asking%20for%20data%20records%20(or%20at%20least%20some%20parts%20of%20each%20record)%20arranged%20in%20columns.%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
New Contributor

Hi, I am trying to combine two columns into one. Column F has the product sold and column G has the postage. I would like to know if it is possible for the amount from column G to be moved to column F by inserting a row in column F for it to be moved to that is not a manual process but a function or macro that can be set up.

Hope that makes sense.

Thanks

6 Replies
Highlighted
That would be the easiest way to do it, of course it can also be done with VBA ... if there are a lot of rows / columns.

F2 G2 H2 Formula H2
TEST CAR TEST CAR =F2&" "&G2

If you liked the solution, please post it as a Best Responses with a like (press thumbs up). If you did not like the solution, please give me a little reply to find a more customized solution for you.

I would be happy to find out if I could help.

Nikolino
I know I don't know anything (Socrates)
Highlighted

@SueDuff 

Here is a macro:

 

Sub InsertAndMove()
    Dim r As Long
    Dim m As Long
    Application.ScreenUpdating = False
    m = Range("F" & Rows.Count).End(xlUp).Row
    For r = m To 2 Step -1
        Range("F" & r + 1).Insert Shift:=xlShiftDown
        Range("F" & r + 1).Value = Range("G" & r).Value
        Range("G" & r).Clear
    Next r
    Application.ScreenUpdating = True
End Sub

 

If you want to insert an entire row instead of only a cell in column G, change the line

 

         Range("F" & r + 1).Insert Shift:=xlShiftDown

 

to

 

         Range("F" & r + 1).EntireRow.Insert Shift:=xlShiftDown

Highlighted

@SueDuff 

 

You wrote:     Hi, I am trying to combine two columns into one....I would like to know if it is possible for the amount from column G to be moved to column F by inserting a row in column F for it to be moved to that is not a manual process but a function or macro that can be set up.

Hope that makes sense.

 

It did make sense, in the sense that you were clear on what you wanted to do. And you've gotten two answers that, I'm assuming, make it possible.

 

There's another way to "making sense" however....and my "sense maker" is wondering "Why?"  As in "Why are you trying to do this in the first place?"   In general--and maybe your situation is an entirely legitimate exception--Excel does very well with information such as you're describing arrayed as an Excel Table, which is to say, one record per row. So such things as a record of a sale would be stored as a single row, arrayed perhaps as

Date.....SKU....ProdID...Quantity.....BuyerName...BuyerAddress....Postage.....

And from that kind of record you could do all kinds of things quite easily....reports on how many of each product were sold in a given month, how many were sold to buyers in NC....whatever. 

 

It's the very great ease of accomplishing almost anything from a database that holds each record as a single row that makes me wonder the "Why?"

 

If all you are doing is creating a report that shows summary numbers by Product of Postage costs to ship, that would be a report.....

 

Anyway, if you could excuse the impertinence of my asking, I'd like to understand how it makes sense in this respect: what was the purpose? 

(There might well have been an easier way to accomplish that purpose.)

 

As an aside, this is particularly interesting because within the last few hours, another user posted a question wanting to go in exactly the opposite direction....turning data in one column but two rows, into one row, two columns.... https://techcommunity.microsoft.com/t5/excel/split-a-column-by-rows/m-p/1543283

That other request makes more sense from a database (or Excel Table) point of view... in that case, my question would have been "Why was it in that other layout in the first place?"

Highlighted
Thanks for the advice. I am looking to create a CSV file that can be upload to an accounting package and it is very specific about the layout or it rejects it. The files I download have all the information I need but in the wrong places (multiple columns) as I need certain information in one column, linked to a name and order number arranged in rows rather than columns.
Highlighted

@Hans Vogelaar I will give it a try, thank you.

Highlighted

@SueDuff 

 

You very nicely replied to my impertinent question of "Why?!": I am looking to create a CSV file that can be upload to an accounting package and it is very specific about the layout or it rejects it. The files I download have all the information I need but in the wrong places (multiple columns) as I need certain information in one column, linked to a name and order number arranged in rows rather than columns.

 

First, thank you for explaining the purpose you were seeking to serve.

Second, your answer, I must say, surprises me. If only for this reason: when I get CSV files from various financial sources--Fidelity, Chase, Citibank, AmEx--they all are arrayed with records in rows, not columns. I.e., in what I'd call standard database fashion. So it is surprising to hear that this accounting package is asking for data records (or at least some parts of each record) arranged in columns.