DonationCoder.com Forum

DonationCoder.com Software => Coding Snacks => Finished Programs => Topic started by: Renegade on January 09, 2011, 11:54 PM

Title: DONE: Utility: Convert Multiple Columns in Excel to a Single Column
Post by: Renegade on January 09, 2011, 11:54 PM
A fellow I work with is not very techno-savvy, and needs to collapse multiple columns in Excel into a single value.

I wrote a little utility to let him copy columns from Excel, paste into the utility, then copy back into a single column in Excel.

UTILITY (Tab Cleaner):
[ You are not allowed to view attachments ]

DOWNLOAD:
[ You are not allowed to view attachments ]

PURPOSE:
Combine multiple columns (and rows) into a single column.

USAGE:
1) Copy columns (and rows) from MS Excel
2) Click first "PASTE" text box in the program
3) In Excel, double click a cell to deselect
4) Select a cell to paste new value(s)
5) Click second "COPY" text box in the program
6) In Excel, paste the value(s)
7) Done.

To change the separator, change the value in the "Tab Cleaner Text" box, e.g. change " - " to " " or ", " or whatever suits your purpose.

Here's an example showing columns I, J, and combined into column L:

[ You are not allowed to view attachments ]


While I'm sure few people here would need it, I'm guessing that someone will find a use.


EDIT (forgot the requirements):

REQUIREMENTS:
Microsoft Windows 2000 or higher
.NET 2.0

Title: Re: Utility: Convert Multiple Columns in Excel to a Single Column
Post by: skwire on January 09, 2011, 11:55 PM
Nicely done.   :Thmbsup:
Title: Re: Utility: Convert Multiple Columns in Excel to a Single Column
Post by: Target on January 10, 2011, 12:45 AM
sorry, don't mean to critical, but couldn't you have just used a concatenation formula (=columnA & columnB & columnC)?

you could use a VBA macro to fill it in and paste the values (no dependencies, apart from Excel)
Title: Re: Utility: Convert Multiple Columns in Excel to a Single Column
Post by: Renegade on January 10, 2011, 01:28 AM
sorry, don't mean to critical, but couldn't you have just used a concatenation formula (=columnA & columnB & columnC)?

you could use a VBA macro to fill it in and paste the values (no dependencies, apart from Excel)

Nope. Not possible. Like I said, "A fellow I work with is not very techno-savvy." :P :)

He'd have to do WAY too much BS to get things working. He can copy, and he can paste, and he can click. Macros? Waaaayyyy out. Get him to copy concatenation formulas (and have dependent cells)? Not gonna fly.

Nope. This was a quick hack to help him get column concatenated quickly without any extra information being needed.

It's hard working with anything in Excel given the funky way that Excel works with the clipboard, so there's that extra step to de-focus/de-select in there, but that's the only thing that's kind of icky.

But normally, yeah -- there are many other ways. This is just designed to work for a particular work-style.
Title: Re: Utility: Convert Multiple Columns in Excel to a Single Column
Post by: Renegade on January 10, 2011, 02:38 AM
Just for interest sake:

Code: C# [Select]
  1. private void textBox1_MouseClick(object sender, MouseEventArgs e)
  2.         {
  3.             this.textBox1.Text = Clipboard.GetText();
  4.             this.textBox2.Text = Clipboard.GetText().Replace("\t", this.textBox3.Text);
  5.         }
  6.  
  7.         private void textBox2_MouseClick(object sender, MouseEventArgs e)
  8.         {
  9.             Clipboard.SetText(this.textBox2.Text);
  10.         }

Stupidly simple. (Should have error checking and stuff, but meh... whatever...)

Title: Re: Utility: Convert Multiple Columns in Excel to a Single Column
Post by: techidave on January 10, 2011, 06:35 AM
Nice Renegade and Thanks for sharing! :Thmbsup: :Thmbsup:

This will come in handy at my school since I have users who aren't tech savy enough to do the concatenation feature.  Heck, I don't use it all that much because I find it too time consuming.  But heck, I have to look up how to do it each and every time I want to combine a few columns.

This will make it so much easier!
Title: Re: Utility: Convert Multiple Columns in Excel to a Single Column
Post by: Target on January 10, 2011, 05:28 PM
Nope. Not possible. Like I said, "A fellow I work with is not very techno-savvy." :P :)

He'd have to do WAY too much BS to get things working. He can copy, and he can paste, and he can click. Macros? Waaaayyyy out. Get him to copy concatenation formulas (and have dependent cells)? Not gonna fly.

Nope. This was a quick hack to help him get column concatenated quickly without any extra information being needed.

It's hard working with anything in Excel given the funky way that Excel works with the clipboard, so there's that extra step to de-focus/de-select in there, but that's the only thing that's kind of icky.

But normally, yeah -- there are many other ways. This is just designed to work for a particular work-style.

Seemed like you were cracking a walnut with a sledgehammer is all, but I figured there was probably a reason.

I still think it could be done without the copy and paste steps via a macro, but I suspect the user will be using this on lots of different source documents

<rant>
Actually this sort of thing really burns me.  I have more than a few colleagues like that (I had someone doing important calculations ask me what the numbers in red were...) and even though they work with Excel all day every day they can't or won't take the time to learn some basics that will make their (working) lives easier
</rant>

Title: Re: Utility: Convert Multiple Columns in Excel to a Single Column
Post by: cranioscopical on January 10, 2011, 08:02 PM
I had someone doing important calculations ask me what the numbers in red were...

And I suppose you told him you sweated blood to get them there…
Title: Re: Utility: Convert Multiple Columns in Excel to a Single Column
Post by: Renegade on January 10, 2011, 08:12 PM
Seemed like you were cracking a walnut with a sledgehammer is all, but I figured there was probably a reason.

I still think it could be done without the copy and paste steps via a macro, but I suspect the user will be using this on lots of different source documents

Yes, yes and yes. :)

Since he'll be using it on different documents, getting him to start using macros and saving them into different files is simply way beyond practical.

It is using a sledgehammer, but anyone can use a sledgehammer. Figuring out how to use some dainty, dancing nutcracker just doesn't work sometimes.
Title: Re: Utility: Convert Multiple Columns in Excel to a Single Column
Post by: Target on January 10, 2011, 08:49 PM
And I suppose you told him you sweated blood to get them there…

no, but it sure gave me pores when she said it...
Title: Re: Utility: Convert Multiple Columns in Excel to a Single Column
Post by: AndyM on January 10, 2011, 09:04 PM
<rant>
Actually this sort of thing really burns me.  I have more than a few colleagues like that (I had someone doing important calculations ask me what the numbers in red were...) and even though they work with Excel all day every day they can't or won't take the time to learn some basics that will make their (working) lives easier
</rant>

Oh yeah, spot on!  

But I'm either getting older and wiser, or just older and wore out.  I was going to chime in with Concatenation Formula! or VBA! (and the code could go in personal.xls to always be available).  But even before Renegade posted his explanation I got to thinking, "if his people are like my people, this really is a simpler solution and will most likely work better because they can't break it".
Title: Re: Utility: Convert Multiple Columns in Excel to a Single Column
Post by: Renegade on January 10, 2011, 09:12 PM
<rant>
Actually this sort of thing really burns me.  I have more than a few colleagues like that (I had someone doing important calculations ask me what the numbers in red were...) and even though they work with Excel all day every day they can't or won't take the time to learn some basics that will make their (working) lives easier
</rant>

Oh yeah, spot on! 

But I'm either getting older and wiser, or just older and wore out.  I was going to chime in with Concatenation Formula! or VBA! (and the code could go in personal.xls to always be available).  But even before Renegade posted his explanation I got to thinking, "if his people are like my people, this really is a simpler solution and will most likely work better because they can't break it".

;)

Setup cost with the program I wrote: Double-click to run.  :Thmbsup:

Setup cost with VBA/macros: Step 1) lose all sanity...  :o

Need I say more? ;)

For anyone that has spent an hour trying to explain over the phone how to open a file... and failed... hehehe -- yeah... it happens... Sometimes ya gotta just pick yer battles. :)
Title: Re: Utility: Convert Multiple Columns in Excel to a Single Column
Post by: AndyM on January 10, 2011, 09:26 PM
 
For anyone that has spent an hour trying to explain over the phone how to open a file... and failed...

stop, please.  I need to go to sleep and I can't if I'm laughing this hard.
Title: Re: Utility: Convert Multiple Columns in Excel to a Single Column
Post by: Target on January 10, 2011, 09:28 PM
the code could go in personal.xls to always be available

actually the easiest way is to put it in an addin (XLA) - save it to the XLSTART directory and put a button on the toolbar...

don't know about that last bit in versions past 2003 (we finally got 'upgraded' about 2 months ago and I'm still struggling with all those productivity gains...)
Title: Re: Utility: Convert Multiple Columns in Excel to a Single Column
Post by: Target on January 10, 2011, 09:48 PM
For anyone that has spent an hour trying to explain over the phone how to open a file... and failed... hehehe -- yeah... it happens... Sometimes ya gotta just pick yer battles. :)

i think you meant bottles...
Title: Re: Utility: Convert Multiple Columns in Excel to a Single Column
Post by: Renegade on January 10, 2011, 10:20 PM
For anyone that has spent an hour trying to explain over the phone how to open a file... and failed... hehehe -- yeah... it happens... Sometimes ya gotta just pick yer battles. :)

i think you meant bottles...

Hahahah~! :P Yep.
Title: Re: Utility: Convert Multiple Columns in Excel to a Single Column
Post by: cranioscopical on January 10, 2011, 10:48 PM
o, but it sure gave me pores when she said it...
You shouldn't have been on your cell!
Title: Re: Utility: Convert Multiple Columns in Excel to a Single Column
Post by: Target on January 10, 2011, 11:10 PM
You shouldn't have been on your cell!

I was only there to help her with her division

Title: Re: Utility: Convert Multiple Columns in Excel to a Single Column
Post by: Perry Mowbray on January 10, 2011, 11:19 PM
actually the easiest way is to put it in an addin (XLA) - save it to the XLSTART directory and put a button on the toolbar...

don't know about that last bit in versions past 2003 (we finally got 'upgraded' about 2 months ago and I'm still struggling with all those productivity gains...)

It would be interesting to know how you go... I've got lots of Excel and Word toolbars around the building and we're looking at upgrading shortly...

Title: Re: Utility: Convert Multiple Columns in Excel to a Single Column
Post by: cranioscopical on January 10, 2011, 11:22 PM
You shouldn't have been on your cell!

I was only there to help her with her division

On the plus side, at least it wasn't done under the table.
Title: Re: Utility: Convert Multiple Columns in Excel to a Single Column
Post by: Target on January 11, 2011, 12:24 AM
It would be interesting to know how you go... I've got lots of Excel and Word toolbars around the building and we're looking at upgrading shortly...

I only have the one, but it's used all over the country.  If and when I do something about it I'll let you know 8)

FYI you're old toolbars will still showup, just not like they used to (they appear under the ADDINS tab of the ribbon, and they can be attached to the quick launch bar)

I have mixed feelings about the 'upgrade' - there are good things (substantially larger worksheets for one), but the interface changes are so drastic that my productivity took a huge hit (this has been discussed elsewhere).  Even 2 months on I still have to go searching for things I used to use all the time
Title: Re: Utility: Convert Multiple Columns in Excel to a Single Column
Post by: Target on January 11, 2011, 12:32 AM
On the plus side, at least it wasn't done under the table.
-cranioscopical (January 10, 2011, 11:22 PM)

but we never did get to the root of the problem
Title: Re: Utility: Convert Multiple Columns in Excel to a Single Column
Post by: Shades on January 11, 2011, 04:06 PM
Why not? The square is not that far away...
Title: Re: Utility: Convert Multiple Columns in Excel to a Single Column
Post by: Renegade on January 11, 2011, 04:27 PM
Some people are just too chicken, and always ask Y they must X the road...
Title: Re: Utility: Convert Multiple Columns in Excel to a Single Column
Post by: Target on January 11, 2011, 04:35 PM
Why not? The square is not that far away...

I simply don't have the power

Some people are just too chicken, and always ask Y they must X the road...

it's because the cars sometimes don't algebraic in time
Title: Re: Utility: Convert Multiple Columns in Excel to a Single Column
Post by: Perry Mowbray on January 11, 2011, 05:53 PM
It would be interesting to know how you go... I've got lots of Excel and Word toolbars around the building and we're looking at upgrading shortly...

I only have the one, but it's used all over the country.  If and when I do something about it I'll let you know 8)

FYI you're old toolbars will still showup, just not like they used to (they appear under the ADDINS tab of the ribbon, and they can be attached to the quick launch bar)

I have mixed feelings about the 'upgrade' - there are good things (substantially larger worksheets for one), but the interface changes are so drastic that my productivity took a huge hit (this has been discussed elsewhere).  Even 2 months on I still have to go searching for things I used to use all the time

Thanks.

Yes I'm concerned not just for my loss of productivity, but the drain on my time sorting everyone else out...
Title: Re: Utility: Convert Multiple Columns in Excel to a Single Column
Post by: Target on January 16, 2011, 06:28 PM
It would be interesting to know how you go... I've got lots of Excel and Word toolbars around the building and we're looking at upgrading shortly...
I only have the one, but it's used all over the country.  If and when I do something about it I'll let you know 8)

Turns out the ribbon is easier to work with than I expected - had some downtime on Friday because of a systems outage so I spent some time on this

As usual the VBA help file is, well, less than helpful.  The info may be there, but I clearly don't know the right questions to ask.

A google search turned up several references but this one (http://www.xtremevbtalk.com/showthread.php?t=265636) did the trick. 

Everythings in XML, and while I won't pretend that I know anything about XML structure or syntax, the structure as used is pretty straight foward. 

Greatest aid is the Custom UI Editor for MS Office (get it here (http://openxmldeveloper.org/articles/CustomUIeditor.aspx)).  It will generate sample code, includes a code validator, and will generate the necessary VBA stubs for you (you need to copy and paste into the editor if you're going to use them).  That last bit is worth noting - it took me a while to twig to the fact that there is a parameter you need to add to the called routines to make the buttons work properly.

No doubt there's more to the whole ribbon interface, but I only needed to get a new tab on the bar for my macro's so that's as far as I've taken it (but YMMV)
Title: Re: Utility: Convert Multiple Columns in Excel to a Single Column
Post by: Renegade on January 16, 2011, 06:58 PM
As usual the VBA help file is, well, less than helpful.  The info may be there, but I clearly don't know the right questions to ask.

I really don't understand why MS doesn't get .NET into MS Office already. You can use it in SQL Server, so why not Office? VBA is, well, painful in comparison.
Title: Re: Utility: Convert Multiple Columns in Excel to a Single Column
Post by: Target on January 16, 2011, 07:27 PM
I really don't understand why MS doesn't get .NET into MS Office already. You can use it in SQL Server, so why not Office? VBA is, well, painful in comparison.

I couldn't comment on that one, though as with many things MS's reasoning defies most accepted forms of logic. 

VBA got me started on coding and I don't know C (in any variation).  From a user perspective .NET seems to be a significant piece of bloatware (who wants to download and install a huge - up 250M -  piece of extra software just so they can write or run a macro...)

That said I'm not averse to learning C, I just don't have a reason at the moment
Title: Re: Utility: Convert Multiple Columns in Excel to a Single Column
Post by: Perry Mowbray on January 16, 2011, 07:58 PM
Thanks for that  :Thmbsup: I'll have to keep this handy for future reference...

VBA's OK after you get used to it, and certainly quick to whip up something  ;)