View Single Post
  #10   Report Post  
Bob Phillips
 
Posts: n/a
Default

Does your data sheet have the headings that you want copy across, or do we
create them on the fly?

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Steved" wrote in message
...
Thankyou, I am Sorry I was not thinking

The sheet is Data I've changed it from Data Sheet
to Data

Question I would like to put in headings in Row 1
Would that be okay

Thankyou again for your patience.


-----Original Message-----
Is your data sheet called something other than 'Data

Sheet'?

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Steved" wrote in

message
...
Hello Bob from Steved

I am getting Subscript out of Range.

Thanks for your patience.


-----Original Message-----
Sorry, correction

Sub Test()
Dim cLastRow As Long
Dim i As Long
Dim iStartRow As Long
Dim iLastRow As Long

With Worksheets("Data Sheet")
cLastRow = .Cells(.Rows.Count, "A").End

(xlUp).Row
iStartRow = 1
iLastRow = 1
For i = 2 To cLastRow + 1
If .Cells(i, "A").Value < Cells(i - _
1, "A").Value Then
iLastRow = i - 1
.Cells(iStartRow, "A").Resize

(iLastRow - _
iStartRow + 1).EntireRow.Copy _
Destination:=Worksheets(.Cells(i -

_
1, "A").Value).Range("A1")
iStartRow = i
iLastRow = i
Else
iLastRow = iLastRow + 1
End If
Next i
End With

End Sub


--

HTH

RP
(remove nothere from the email address if mailing

direct)


"Bob Phillips"

wrote
in message
...
Probably wrap-around in the NG Steved.

Try this split version

Sub Test()
Dim cLastRow As Long
Dim i As Long
Dim iStartRow As Long
Dim iLastRow As Long

With Worksheets("Data Sheet")
cLastRow = .Cells(.Rows.Count, "A").End
(xlUp).Row
iStartRow = 1
iLastRow = 1
For i = 2 To cLastRow + 1
If .Cells(i, "A").Value < Cells(i - _
1, "A").Value Then iLastRow = i - 1
.Cells(iStartRow, "A").Resize

(iLastRow -
_
iStartRow +

1).EntireRow.Copy _
Destination:=Worksheets(.Cells

(i - _
1, "A").Value).Range("A1")
iStartRow = i
iLastRow = i
Else
iLastRow = iLastRow + 1
End If
Next i
End With

End Sub

--

HTH

RP
(remove nothere from the email address if mailing
direct)


"Steved" wrote

in
message
...
Hello from Steved

Firstly thankyou very much

The macro is highlighting "Else"

giving me Compile error, ELSE without IF

Please what is required here. Thanks very much in
advance.

Sub Test()
Dim cLastRow As Long
Dim i As Long
Dim iStartRow As Long
Dim iLastRow As Long

With Worksheets("Data Sheet")
cLastRow = .Cells(.Rows.Count, "A").End
(xlUp).Row
iStartRow = 1
iLastRow = 1
For i = 2 To cLastRow + 1
If .Cells(i, "A").Value < Cells(i -
1, "A").Value Then iLastRow = i - 1
.Cells(iStartRow, "A").Resize
(iLastRow -
iStartRow + 1).EntireRow.Copy _
Destination:=Worksheets(.Cells

(i -
1, "A").Value).Range("A1")
iStartRow = i
iLastRow = i
Else
iLastRow = iLastRow + 1
End If
Next i
End With

End Sub







-----Original Message-----
Steved,

This assumes that all of those worksheets exist

Sub Test()
Dim cLastRow As Long
Dim i As Long
Dim iStartRow As Long
Dim iLastRow As Long

With Worksheets("Data Sheet")
cLastRow = .Cells(.Rows.Count, "A").End
(xlUp).Row
iStartRow = 1
iLastRow = 1
For i = 2 To cLastRow + 1
If .Cells(i, "A").Value < Cells(i -
1, "A").Value Then
iLastRow = i - 1
.Cells(iStartRow, "A").Resize
(iLastRow -
iStartRow +
1).EntireRow.Copy _
Destination:=Worksheets(.Cells
(i - 1,
"A").Value).Range("A1")
iStartRow = i
iLastRow = i
Else
iLastRow = iLastRow + 1
End If
Next i
End With

End Sub


--

HTH

RP
(remove nothere from the email address if mailing
direct)


"Steved"

wrote
in
message
...
Hello from Steved

I have sheet1 labeled Data, Where the below is
stored

I've Labeled 8 Sheets as an example 1-City, 2-
Roskill
and so on. Question in vba please could somebody
please
write me a code that would copy from the Data
Sheet to
the 8 individual labeled sheets. Thankyou.

Depot,Name Operator,Count Annuls,Annul Value

Total,
Period
1-City 10925 27 29.60 200511
1-City 10943 27 54.90 200511
6-Orewa 60124 28 67.44 200511
6-Orewa 60123 17 42.10 200511
8-Panmure 10903 27 54.04 200511
8-Panmure 10915 27 45.80 200511
3-Papakura 86076 48 122.70 200511
3-Papakura 86030 30 69.54 200511
2-Roskill 20824 42 35.38 200511
2-Roskill 20751 36 83.30 200511
5-Shore 50636 40 82.60 200511
5-Shore 50600 34 104.80 200511
7-Swanson 70468 40 59.94 200511
7-Swanson 70478 39 109.50 200511
4-Wiri 40677 35 64.40 200511
4-Wiri 40662 28 58.00 200511



.





.



.