Try this out:
Option Explicit
Sub ParsePricingData()
'Author: Jerry Beaucaire, ExcelForum.com
'Date: 11/3/2010
Dim Sh1 As Worksheet: Set Sh1 = Sheets("Sheet1") 'the raw data sheet
Dim Sh2 As Worksheet: Set Sh2 = Sheets("Sheet2") 'the good pricing sheet
Dim Sh3 As Worksheet: Set Sh3 = Sheets("Sheet3") 'the bad pricing sheet
Dim Stocks As Range: Set Stocks = Sh1.Range("A:A").SpecialCells(xlConstants)
Dim Stk As Range
Dim NR As Long, Rw As Long, LR As Long, C As Long
LR = Sh1.Cells.Find("*", Cells(Rows.Count, Columns.Count), SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
Application.ScreenUpdating = False
For Each Stk In Stocks
If Stk.Value <> "Stock code :" Then GoTo NextStk
If Left(Sh1.Range("R" & Stk.Row), 14) = "List price: 0." Then
With Sh3
NR = .Range("A" & Rows.Count).End(xlUp).Row + 1
.Range("A" & NR).Value = Sh1.Range("B" & Stk.Row).Value
.Range("B" & NR).Value = Sh1.Range("B" & Stk.Row + 1).Value
.Range("C" & NR).Value = Sh1.Range("R" & Stk.Row).Value
End With
Else
With Sh2
NR = .Range("A" & Rows.Count).End(xlUp).Row + 1
.Range("A" & NR).Value = Sh1.Range("B" & Stk.Row).Value
.Range("B" & NR).Value = Sh1.Range("B" & Stk.Row + 1).Value
.Range("C" & NR).Value = Sh1.Range("R" & Stk.Row).Value
Rw = Stk.Row + 4
Do
If IsNumeric(Sh1.Range("H" & Rw)) And Sh1.Range("R" & Rw) <> 0 Then _
Sh1.Range("H" & Rw & ",R" & Rw).Copy _
Sh2.Cells(NR, Columns.Count).End(xlToLeft).Offset(, 1)
Rw = Rw + 1
If Rw > LR Then Exit Do
Loop Until Sh1.Cells(Rw, "A") <> ""
End With
End If
NextStk: Next Stk
With Sh2
For C = 5 To .Cells(1, .Columns.Count).End(xlToLeft).Column Step 2
.Columns(C).NumberFormat = "0.00"
Next C
.UsedRange.Font.Size = 8
.UsedRange.Font.Name = "Arial"
.UsedRange.Interior.ColorIndex = xlNone
End With
Application.ScreenUpdating = True
End Sub
Bookmarks