Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / May 2008

Tip: Looking for answers? Try searching our database.

I am not sure

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Frank Pytel - 09 May 2008 01:15 GMT
Hello;

I am trying to help someone, for which I am not sure there exists a
solution. He has a .csv file that he is opening in Excel. The values,
somehow, import into the correct conglomeration of data. More in a minute.

Column A is a number formatted as text. Column B is a series of numbers,
some formatted as text. Those that are not formatted as text, are separated
by commas (Huh!!) and hyphens.

The object is to concatenate the two values together. Example:

A           |  B           | C
            |               |
1           | 357         |Argentina
            |               |
345        |32,34,39  |Paraguay
            | 40-45      |
            |               |
33945    |27-30,41, | USA
            |43, 45      |

The data should finally look like this for USA (etc.)

A            | B
3394527  |USA
3394528  |USA
3394529  |USA
3394530  |USA
3394541  |USA
3394543  |USA
3394545  |USA

Which column the new values end up in does not matter. I know how to do this
fairly rapidly with formula's and a big enough worksheet. Then copy and paste
the values to where I want them.

I am wondering if this is even possible. I am not a big VB fan. I like to
avoid them if I can, but I wonder if this can even be handeled by VB. Column
B on one of the cells looks like this as an example.

264235, 264469, 264476, 264497, 264536-264539, 264543, 264581-264584,
264724, 264729, 264772-264773

There is no regularity to the number of digits. There is no regularity to
the hyphenation location. There is no regularity to the format of the numbers
(which I guess all could be changed to numbers and back to text for
concantenation) and there is no regularity to the quantity of values in the
cell.

Is there any hope for this? Any help would be appreciated.

Thank You

Frank Pytel

PS. I see a lot of posts here that look really nice. I am on the Office
Online site. I know these posts can be viewed and edited at other sites. Can
I set this up in Outlook so that I can Post and search. Kind of like Outlook
Express? Thanks
Bob Bridges - 09 May 2008 01:53 GMT
It absolutely can be done in VB; in fact I would say, theoretically, that any
full programming language can do it, even if some can do it more easily than
others.  This one would be easier to do in other languages, but it wouldn't
be really easy in any language - possibly excepting REXX, and maybe LISP if I
knew LISP - and if Excel is where the data is stored then it's probably the
right place to process it.

Let's see, now.  There may be a more elegant way to do it, but I think each
string in column B can be parsed as follows:

1) Change every string of consecutive <space>s to a single <space>.
2) Next change every occurrence of <space><hyphen> and <hyphen><space> to a
single <hyphen>.
3) Next change every occurrence of <comma>, <space><comma> and
<comma><space> to a single <space>.

Now you have a string consisting simply of "<i> <j>-<k> <l>" etc.  You can
take each space-delimited group in turn.  Each one that has a hyphen in it
can be divided and then turned into a list of numbers <j> through <k>, and
each group without a hyphen is number by itself.  Each number thus generated
must be concatenated to the value in column A and written to a new cell in
your resulting list.

As I said, this isn't exactly elegant, but it's more easily described than
some of the solutions that would run faster.  How much detail do you want to
get into?

> I am trying to help someone, for which I am not sure there exists a solution. He
> has a .csv file that he is opening in Excel. The values, somehow, import into the
[quoted text clipped - 50 lines]
> I set this up in Outlook so that I can Post and search. Kind of like Outlook
> Express? Thanks
Frank Pytel - 09 May 2008 17:54 GMT
Bob;

Sounds easy enough. I would certainly like to see code to this affect. The
VB that I know is limited, but it sounds intriguing. I am not sure at all
that I see this working.

Can you point me to some of the code for the hyphen portion and for deleting
commas.

Thanks Bob. Have a Great Day.

Frank Pytel

> It absolutely can be done in VB; in fact I would say, theoretically, that any
> full programming language can do it, even if some can do it more easily than
[quoted text clipped - 77 lines]
> > I set this up in Outlook so that I can Post and search. Kind of like Outlook
> > Express? Thanks
Rick Rothstein (MVP - VB) - 09 May 2008 21:12 GMT
The VB I know is not all that limited at all. Just out of curiosity, which
version of VBA are you using?

Rick

> Bob;
>
[quoted text clipped - 118 lines]
>> > Outlook
>> > Express? Thanks
Frank Pytel - 09 May 2008 22:33 GMT
Hey Rick;

I am not sure. I don't do much. It says 6.5.1024 is the retail version. It
is called Mircorsoft Visual Basic 6.5.

God Bless

Frank Pytel

> The VB I know is not all that limited at all. Just out of curiosity, which
> version of VBA are you using?
[quoted text clipped - 123 lines]
> >> > Outlook
> >> > Express? Thanks
Frank Pytel - 09 May 2008 22:34 GMT
Hey Rick;

My VBA is limited, not the programs I am sure.

Frank Pytel

> The VB I know is not all that limited at all. Just out of curiosity, which
> version of VBA are you using?
[quoted text clipped - 123 lines]
> >> > Outlook
> >> > Express? Thanks
Jeff Johnson - 09 May 2008 16:12 GMT
> PS. I see a lot of posts here that look really nice. I am on the Office
> Online site. I know these posts can be viewed and edited at other sites.
> Can
> I set this up in Outlook so that I can Post and search. Kind of like
> Outlook
> Express? Thanks

Outlook Express is where you want to be. It's a newsreader, and this is a
newsgroup, NOT a Web site, even though you may be reading it through a Web
application which makes it APPEAR to be a Web site/forum.

Anyways, in OE, set up a News account and point it to msnews.microsoft.com,
then subscribe to microsoft.public.excel.programming.

Of course, there are other newsreaders out there, some even free, but OE is
basically guaranteed to already be on the (Windows) machine you're using.
Frank Pytel - 09 May 2008 17:51 GMT
Thanks Jeff;

Frank Pytel

> > PS. I see a lot of posts here that look really nice. I am on the Office
> > Online site. I know these posts can be viewed and edited at other sites.
[quoted text clipped - 12 lines]
> Of course, there are other newsreaders out there, some even free, but OE is
> basically guaranteed to already be on the (Windows) machine you're using.

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.