Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
3e 3e is offline
external usenet poster
 
Posts: 1
Default Splitting up code ribbon

I receive code ribbons of 170 characters long.
eg:aar34cvf5hyj8dfg23bhy8.............
how can I split these automatically into
a1: aar a2:34
b1:cvf b2:5
these ribbons very in lead dut 2 to the different figures. they are allso no
spaces in between
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Splitting up code ribbon

Maybe...

Select the range and do data|text to columns (in xl2003 menus).

You'll be shown a wizard. You can specify that your text is made up of fixed
width fields. You can draw lines at each each field and excel will follow your
rules to parse the data into different columns.

3e wrote:

I receive code ribbons of 170 characters long.
eg:aar34cvf5hyj8dfg23bhy8.............
how can I split these automatically into
a1: aar a2:34
b1:cvf b2:5
these ribbons very in lead dut 2 to the different figures. they are allso no
spaces in between


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,365
Default Splitting up code ribbon

Dave Peterson offered one potential solution, but it wouldn't give you the 2
row solution you've asked for. The code below could be a solution to the
problem. It makes a couple of assumptions:
#1 that you put the 170 character code ribbon into cell A3 on a sheet, and
#2 that the results will be put into rows 1 and 2 of that same sheet, and
#3 that you have that sheet selected when you run this macro, AND
#4 BIG ONE - that the 170 characters start with an alpha group (abc), not a
group of digits as 123.

If you wish to retain leading zeros in numeric groups, you should format row
2 on the sheet as Text instead of zero, otherwise groups like "007" will
appear on the sheet in row two as 7.

To put the code into your workbook: Open the workbook, press [Alt]+[F11] to
open the VB Editor (VBE). In the VBE choose Insert | Module and then copy
the code below and paste it into the module presented to you. Close the VBE.

To use it: put your 170 character code ribbon into cell A3 of a sheet and
then choose Tools | Macro | Macros and select the SplitCodeRibbon macro and
click the [Run] button.

The code's probably not as tight/efficient as it could be, but it does seem
to meet one critical aspect of "good code": it produces reliable results when
used with data that meets the description you've provided for a 'code ribbon'.

Sub SplitCodeRibbon()
Const alphas = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
Const digits = "0123456789"
Dim workingData As String
Dim alphaGroup As String
Dim digitsGroup As String
Dim positionPointer As Integer

'erase any previous entries in rows 1 & 2
ActiveSheet.Rows("1:2").ClearContents
'position for first entry
ActiveSheet.Range("A1").Activate

'get raw information to work with
workingData = ActiveSheet.Range("A3")
Application.ScreenUpdating = False ' for speed
Do While Len(workingData) 0
'clear any previous results
alphaGroup = ""
digitsGroup = ""
positionPointer = 1
'assumes alpha group starts the whole thing
Do While InStr(alphas, UCase(Mid(workingData, _
positionPointer, 1)))
alphaGroup = alphaGroup & Mid(workingData, _
positionPointer, 1)
positionPointer = positionPointer + 1
Loop
workingData = Right(workingData, _
Len(workingData) - positionPointer + 1)
positionPointer = 1
Do While InStr(digits, UCase(Mid(workingData, _
positionPointer, 1)))
digitsGroup = digitsGroup & Mid(workingData, _
positionPointer, 1)
positionPointer = positionPointer + 1
'safety valve for last group
If positionPointer Len(workingData) Then
digitsGroup = workingData
workingData = ""
positionPointer = 0
Exit Do '
End If
Loop
If positionPointer 0 Then
workingData = Right(workingData, _
Len(workingData) - positionPointer + 1)
End If
ActiveCell = alphaGroup
ActiveCell.Offset(1, 0) = digitsGroup
ActiveCell.Offset(0, 1).Activate
Loop
End Sub


"3e" wrote:

I receive code ribbons of 170 characters long.
eg:aar34cvf5hyj8dfg23bhy8.............
how can I split these automatically into
a1: aar a2:34
b1:cvf b2:5
these ribbons very in lead dut 2 to the different figures. they are allso no
spaces in between

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
ribbon problems alain Excel Discussion (Misc queries) 3 April 28th 08 12:39 AM
Can we modify any of the ribbon tabs or create new ribbon tabs? Scott Sornberger New Users to Excel 2 March 19th 08 11:41 AM
Excel Ribbon Rhonda New Users to Excel 5 March 7th 08 09:46 AM
Addins tab on ribbon Techtrainer Excel Discussion (Misc queries) 2 January 25th 08 02:38 PM
Toolbars to ribbon DRA New Users to Excel 1 September 28th 07 10:57 PM


All times are GMT +1. The time now is 12:06 AM.

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

About Us

"It's about Microsoft Excel"