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 into different sheets

I have rows that look like this

20050901 2343;3432
20060823 2232;2321
20050401 2322;4434

I want to parse the values into a separate sheet.

New sheet should look like:

Year Code
-------------------------
2005 2343
2005 3432
2006 2232
2006 2321
2005 2322
2005 4434

Any help would be appreciated.

Thanks

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Parsing into different sheets

dthis works. I assumed data started in column A1. Also assume code with
semicolons was in column B.

Sub parsecolumns()

Const oldsheet = "Sheet1"
Const newsheet = "sheet2"

Dim MyYear As String

Sheets(oldsheet).Activate
LastRow = Cells(Rows.Count, 1).End(xlUp).Row
Set DataRange = Range(Cells(1, 1), Cells(LastRow, 1))

Sheets(newsheet).Cells(1, 1) = "Year"
Sheets(newsheet).Cells(1, 2) = "Code"

RowCount = 2
For Each cell In DataRange

MyYear = Left(cell.Value, 4)
CodeString = cell.Offset(rowoffset:=0, columnoffset:=1).Value

Do While InStr(CodeString, ";") 0

NewCode = Left(CodeString, InStr(CodeString, ";") - 1)
CodeString = Mid(CodeString, InStr(CodeString, ";") + 1)

Sheets(newsheet).Cells(RowCount, 1) = MyYear
Sheets(newsheet).Cells(RowCount, 2) = NewCode

RowCount = RowCount + 1

Loop

Sheets(newsheet).Cells(RowCount, 1) = MyYear
Sheets(newsheet).Cells(RowCount, 2) = CodeString
RowCount = RowCount + 1

Next cell


End Sub


"BerkshireGuy" wrote:

I have rows that look like this

20050901 2343;3432
20060823 2232;2321
20050401 2322;4434

I want to parse the values into a separate sheet.

New sheet should look like:

Year Code
-------------------------
2005 2343
2005 3432
2006 2232
2006 2321
2005 2322
2005 4434

Any help would be appreciated.

Thanks


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
Parsing Saxman[_2_] Excel Discussion (Misc queries) 3 July 30th 07 04:36 PM
Parsing data into seperate sheets BerkshireGuy Excel Programming 2 January 19th 07 12:24 AM
Instead of Parsing Krish Excel Discussion (Misc queries) 1 November 4th 06 08:32 PM
Parsing a name Budget Programmer Excel Programming 2 August 19th 06 05:13 AM
Parsing help Richard[_12_] Excel Programming 0 July 27th 03 12:50 PM


All times are GMT +1. The time now is 07:37 AM.

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"