Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Parsing data into seperate sheets

I have many rows with a cell that looks like this:

2134;2345;2342
2123;2343
2322

So each of these cells can containe one or more numbers seperated by a
semicolon.

I need to parse these numbers out and place them in a seperate
worksheet, preferable in one column so that I can easily do a count of
unqiue values.

How can I do this via code. I rather not having the user needing to use
the Text to columns option..

Thanks
B

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default Parsing data into seperate sheets

B,

Insert a new, blank worksheet named ParsedValues into your workbook, then
run this macro with a single cell in the column of data selected

Sub SplitOutValues()
Dim myCell As Range
Dim myR As Range
Set myR = Intersect(ActiveCell.EntireColumn, ActiveSheet.UsedRange)
Dim myV As Variant
Dim i As Integer

Worksheets("ParsedValues").Range("A1").Value = "Parsed values"
For Each myCell In myR
myV = Split(myCell.Value, ";")
For i = LBound(myV) To UBound(myV)
Worksheets("ParsedValues").Range("A65536").End(xlU p)(2).Value = myV(i)
Next i
Next myCell
End Sub

HTH,
Bernie
MS Excel MVP


"BerkshireGuy" wrote in message
oups.com...
I have many rows with a cell that looks like this:

2134;2345;2342
2123;2343
2322

So each of these cells can containe one or more numbers seperated by a
semicolon.

I need to parse these numbers out and place them in a seperate
worksheet, preferable in one column so that I can easily do a count of
unqiue values.

How can I do this via code. I rather not having the user needing to use
the Text to columns option..

Thanks
B



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 694
Default Parsing data into seperate sheets

Hi,

This little macro should do the job.

Copy the sheet first.

Option Explicit

Sub parseit()
' tests the current row region
' where the cell pointer is

Const cSep As String = ";"

Dim lRowLast As Long, _
lRowFirst As Long, _
lRow As Long, _
lRowInsert As Long, _
lCol As Long, _
lRowOffset As Long, _
sCell As String, _
iPtr As Integer

lRowFirst = ActiveCell.CurrentRegion.Row
lRowLast = lRowFirst + ActiveCell.CurrentRegion.Rows.Count - 1
lCol = ActiveCell.CurrentRegion.Column

For lRow = lRowLast To lRowFirst Step -1
sCell = Cells(lRow, lCol)
lRowInsert = lRow
Do
iPtr = InStr(1, sCell, cSep)
If iPtr 0 Then
lRowInsert = lRowInsert + 1
Rows(lRowInsert).Insert
Cells(lRowInsert, lCol) = Left(sCell, iPtr - 1)
sCell = Mid(sCell, iPtr + 1, Len(sCell))
End If
Loop Until iPtr = 0
Cells(lRow, lCol) = sCell
Next lRow

End Sub

--
Hope this helps
Martin Fishlock, Bangkok, Thailand
Please do not forget to rate this reply.


"BerkshireGuy" wrote:

I have many rows with a cell that looks like this:

2134;2345;2342
2123;2343
2322

So each of these cells can containe one or more numbers seperated by a
semicolon.

I need to parse these numbers out and place them in a seperate
worksheet, preferable in one column so that I can easily do a count of
unqiue values.

How can I do this via code. I rather not having the user needing to use
the Text to columns option..

Thanks
B


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
add two cells from seperate work sheets into a cell on seperate wo lar Excel Worksheet Functions 6 April 27th 10 06:54 PM
Seperate data from one sheet to multiple sheets based on a column [email protected] Excel Discussion (Misc queries) 7 September 8th 07 12:31 AM
Auto insert data to seperate sheets? greig2000_uk New Users to Excel 2 May 27th 06 01:10 PM
Vlook up for matching data in two seperate sheets funky via OfficeKB.com Excel Discussion (Misc queries) 1 June 3rd 05 10:16 PM
Import data into seperate sheets CPower[_23_] Excel Programming 8 July 22nd 04 01:14 PM


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

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"