Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default String manipulation from one cell broken up into multiple columns

I need to break a mixed charater string from a single cell into multiple cells. For Example F62T-L needs to be broken down into seperate columns = F, 62, T, L. The hitch comes with the string K500BB-PS, I need it to break down into K, 500, BB, P and S. The tough one will be the "PS", sometimes it's there, sometimes it's just the P, sometimes it's three characters. As a an added items, the number I would like to convert from text to a number value. I could do all of this by hand, we're only talking 150 to 200 entries, but having it automated would be nice. Appreciate any help.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,080
Default String manipulation from one cell broken up into multiple columns

Is the string always in the form letters|numbers|letters|dash|letters?

--

Vasant

"Paul Holmes" wrote in message
...
I need to break a mixed charater string from a single cell into multiple

cells. For Example F62T-L needs to be broken down into seperate columns =
F, 62, T, L. The hitch comes with the string K500BB-PS, I need it to break
down into K, 500, BB, P and S. The tough one will be the "PS", sometimes
it's there, sometimes it's just the P, sometimes it's three characters. As
a an added items, the number I would like to convert from text to a number
value. I could do all of this by hand, we're only talking 150 to 200
entries, but having it automated would be nice. Appreciate any help.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 93
Default String manipulation from one cell broken up into multiple columns

This is one solution based on your string. I am sure you can adapt it to variations in the string

Sub split(
a = "K500BB-PSD
' Guard against - being last characte
dashExists = InStr(a, "-"
dashExists = dashExists < Len(a
a = Replace(a, "-", ","
For i = 1 To Len(a
If IsNumeric(Mid(a, i, 1)) The
a = Replace(a, Mid(a, i, 1), "," & Mid(a, i, 1)
Exit Fo
End I
Nex
For j = i + 2 To Len(a
If Not IsNumeric(Mid(a, j, 1)) The
a = Left(a, j) & "," & Mid(a, j
Exit Fo
End I
Nex
If dashExists The
While InStrRev(a, ",") < Len(a) -
i = 2 + InStrRev(a, ","
For j = i To Len(a
a = Replace(a, Mid(a, j, 1), "," & Mid(a, j, 1)
Exit Fo
Nex
Wen
End I
MsgBox
End Su

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 93
Default String manipulation from one cell broken up into multiple columns

Please chang

a = Left(a, j) & "," & Mid(a, j
to

a = Left(a, j - 1) & "," & Mid(a, j)
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default String manipulation from one cell broken up into multiple columns

Thanks for the help to all. Question 1, There will never be a dash at
the end. Reply 1 & 2. I'll try the subroutine, it also gives me an
informative starting point for improvements or ideas if the format
changes.



*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
String Manipulation within VBA BillCPA Excel Discussion (Misc queries) 2 December 6th 06 05:29 PM
String Manipulation String Manipulation Excel Discussion (Misc queries) 3 November 30th 05 11:51 PM
VBA String manipulation Frank Kabel Excel Programming 2 March 5th 04 07:19 AM
VBA String manipulation Chip Pearson Excel Programming 0 March 4th 04 11:02 PM
String Manipulation Ray Batig Excel Programming 3 December 23rd 03 12:31 AM


All times are GMT +1. The time now is 07:52 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"