hamistasty
Board Regular
- Joined
- May 17, 2011
- Messages
- 208
I'm running this loop which works great thanks to Alpha:
Which basically copies a row of data into a copied template sheet and loops until there are no rows left.
What I'm asking for is code so that before it starts it checks column A for FIC001 to FIC040, and if for example the cells value is FIC001 then it will run the FIC001 loop above.
Thanks!
Code:
Sub FIC001()
Dim ws As Worksheet, Lastrow As Long, i As Long
Sheets("FIC001").Visible = True
Set ws = Sheets("FIC001")
With Sheets("Schedule")
.Range("B1").Copy ws.Range("B4:E4")
.Range("B2").Copy ws.Range("B5:E5")
.Range("B3").Copy ws.Range("G4:J4")
Lastrow = .Range("C" & Rows.Count).End(xlUp).Row
For i = 5 To Lastrow
.Range("A" & i).Copy ws.Range("G14:J14")
.Range("B" & i).Copy ws.Range("B14:E14")
.Range("C" & i).Copy ws.Range("G11:J11")
.Range("D" & i).Copy ws.Range("B11:E11")
.Range("E" & i).Copy ws.Range("G10:H10")
.Range("F" & i).Copy ws.Range("B10:E10")
.Range("G" & i).Copy ws.Range("J10")
.Range("H" & i).Copy ws.Range("B7:E7")
.Range("I" & i).Copy ws.Range("G7:J7")
.Range("J" & i).Copy ws.Range("B15:E15")
.Range("K" & i).Copy ws.Range("B8:J8")
ws.Copy After:=Sheets(Sheets.Count)
Sheets(Sheets.Count).Name = .Range("C" & i) & " " & "-" & " " & .Range("J" & i).Value
Next i
End With
ws.Range("B4:E4, B5:E5, G4:J4, G14:J14, B14:E14, G11:J11, B11:E11, J10, " & _
"G10:H10, B10:E10, B7:E7, G7:J7, B15:E15, B8:J8").ClearContents
Sheets("FIC001").Visible = False
Sheets(1).Select
End Sub
Which basically copies a row of data into a copied template sheet and loops until there are no rows left.
What I'm asking for is code so that before it starts it checks column A for FIC001 to FIC040, and if for example the cells value is FIC001 then it will run the FIC001 loop above.
Thanks!