S
Steved
Hello from Steved
The below Macro's objective is to copy then paste into prenamed worksheets
For example it is a sheet1 called Data, in Col A it has 1-City I've named
Sheet2 as 1-City, I am asking that it copies the Values in Col A to Col E
that has 1-City in Col A to the named Sheet "!-City" and paste in Col A2 As
I've given Col A1 a Heading, Ive named the other Sheets 2-Rosk, 4-Wiri,
5-Shor, 6-Orew, 7-Swan, 8-Panm all getting the Values from The sheet Named
Data. Yes Copy values From Sheet Called Data to the other named sheets as
Labeled above.
Below is giving me out of script range.
Please What is required for it to work.
ps no if you have a better way off Acieving a result please show me Thankyou.
Ok simply put, Look in Sheet Called Data, copy Values and put in appropriate
paste into Sheets.
Sub AnulToDepots()
Dim cLastRow As Long
Dim i As Long
Dim iStartRow As Long
Dim iLastRow As Long
With Worksheets("Data")
cLastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
iStartRow = 1
iLastRow = 1
For i = 3 To cLastRow + 1
If .Cells(i, "A").Value <> Cells(i - _
1, "A").Value Then
iLastRow = i - 1
.Cells(1, "A").EntireRow.Copy _
Destination:=Worksheets(.Cells(i - _
1, "A").Value).Range("A1")
.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
The below Macro's objective is to copy then paste into prenamed worksheets
For example it is a sheet1 called Data, in Col A it has 1-City I've named
Sheet2 as 1-City, I am asking that it copies the Values in Col A to Col E
that has 1-City in Col A to the named Sheet "!-City" and paste in Col A2 As
I've given Col A1 a Heading, Ive named the other Sheets 2-Rosk, 4-Wiri,
5-Shor, 6-Orew, 7-Swan, 8-Panm all getting the Values from The sheet Named
Data. Yes Copy values From Sheet Called Data to the other named sheets as
Labeled above.
Below is giving me out of script range.
Please What is required for it to work.
ps no if you have a better way off Acieving a result please show me Thankyou.
Ok simply put, Look in Sheet Called Data, copy Values and put in appropriate
paste into Sheets.
Sub AnulToDepots()
Dim cLastRow As Long
Dim i As Long
Dim iStartRow As Long
Dim iLastRow As Long
With Worksheets("Data")
cLastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
iStartRow = 1
iLastRow = 1
For i = 3 To cLastRow + 1
If .Cells(i, "A").Value <> Cells(i - _
1, "A").Value Then
iLastRow = i - 1
.Cells(1, "A").EntireRow.Copy _
Destination:=Worksheets(.Cells(i - _
1, "A").Value).Range("A1")
.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