Hi Slurpie... so I just had a brain wave, and thought maybe it would be easier to take my original spreadsheet and first delete all the irrelevent coloumns. I used the macro recorder to do this and it seems to work (see below). So I thought I could
1. run the macro to copy the data in 'Data', exlcluding the coloumns I dont want into 'Sheet 1'
2. then run the second macro that I wrote in the previous post to pull in the data I need from 'Sheet 1' to another sheet, 'Sheet 2'.
This probably isnt the most efficent way to do things, but hey !
... and that leaves me needing to alter my code in step 2. to leave a blank line inbwteen Shop A's Apples, Shop A's Pears etc. I also wanted to total up at the side, the price totals....(see example below)
SHOP A STAT 1 STAT 2 APPLES 2.30
SHOP A STAT 1 STAT 2 APPLES 2.30
4.60
SHOP A STAT 1 STAT 2 PEARS 3.40
SHOP A STAT 1 STAT 2 PEARS 4.10
7.50
This is the macro recorder code for copying data and deleting some columns -
Range("A1").Select
Sheets("Data").Select
Cells.Select
Selection.Copy
Sheets("Sheet1").Select
ActiveSheet.Paste
Columns("A:A").Select
Application.CutCopyMode = False
Selection.Delete Shift:=xlToLeft
Columns("B:C").Select
Selection.Delete Shift:=xlToLeft
Columns("C

").Select
Selection.Delete Shift:=xlToLeft
Columns("E:F").Select
Selection.Delete Shift:=xlToLeft
ActiveWindow.SmallScroll ToRight:=5
Columns("G:H").Select
Selection.Delete Shift:=xlToLeft
Columns("H:H").Select
Selection.Delete Shift:=xlToLeft
Selection.Delete Shift:=xlToLeft
ActiveWindow.SmallScroll ToRight:=3
Columns("J:K").Select
Selection.Delete Shift:=xlToLeft
Columns("K:M").Select
Selection.Delete Shift:=xlToLeft
Columns("L:N").Select
Selection.Delete Shift:=xlToLeft
Columns("L:AB").Select
Selection.Delete Shift:=xlToLeft
ActiveWindow.ScrollColumn = 1
ActiveWindow.SmallScroll Down:=9
This is the code I need to alter for the blank lines and totals -
Sub Macro1()
Application.ScreenUpdating = False
Sheets("Data").Select
Lastrow = Range("A65536").End(xlUp).Row
For i = 1 To Lastrow
Sheets("Data").Select
If Cells(i, 2) = "SHOP A" _
And Cells(i, 12) = "APPLES" Then
Rows(i & ":" & i).Select
Selection.Copy
Sheets("Sheet3").Select
PasteRow = Range("F65536").End(xlUp).Offset(1, 0).Row
Rows(PasteRow & ":" & PasteRow).Select
Selection.Insert Shift:=xlDown
End If
Next i
Range("A1").Select
Application.ScreenUpdating = True
Application.ScreenUpdating = False
Sheets("Data").Select
Lastrow = Range("A65536").End(xlUp).Row
For i = 1 To Lastrow
Sheets("Data").Select
If Cells(i, 2) = "SHOP A" _
And Cells(i, 12) = "PEARS" Then
Rows(i & ":" & i).Select
Selection.Copy
Sheets("Sheet3").Select
PasteRow = Range("F65536").End(xlUp).Offset(1, 0).Row
Rows(PasteRow & ":" & PasteRow).Select
Selection.Insert Shift:=xlDown
End If
Next i
Range("A1").Select
Application.ScreenUpdating = True
End Sub
THANKS IN ADVANCE !!!!!