search column and output results in new worksheet in a different o
You only showed 2 locations, so this assumes two locations.
Sub MakeSchedules()
Dim sh As Worksheet, sh1 As Worksheet
Set sh = ActiveSheet
If LCase(sh.Cells(1, 1).Value) < "name" Then
MsgBox "Schedule isn't the active sheet"
Exit Sub
End If
Set rng = sh.Range(sh.Cells(2, 1), sh.Cells(2, 1).End(xlDown))
For i = 3 To 11 Step 2
Worksheets.Add after:=Worksheets(Worksheets.Count)
Set sh1 = ActiveSheet
sh1.Name = sh.Cells(1, i)
sh1.Cells(1, 1) = sh.Cells(1, i)
sh1.Cells(2, 1) = "Inside"
rw1 = 3
rw2 = rw1 + rng.Count + 1
sh1.Cells(rw2, 1) = "l5"
rw2 = rw2 + 1
For Each cell In rng
If LCase(cell.Offset(0, i)) = "inside" Then
sh1.Cells(rw1, 1) = cell.Offset(0, i - 1).Value
sh1.Cells(rw1, 1).NumberFormat = "hh:mm"
sh1.Cells(rw1, 2).Value = cell
rw1 = rw1 + 1
ElseIf LCase(cell.Offset(0, i)) = "l5" Then
sh1.Cells(rw2, 1) = cell.Offset(0, i - 1).Value
sh1.Cells(rw2, 1).NumberFormat = "hh:mm"
sh1.Cells(rw2, 2).Value = cell
rw2 = rw2 + 1
End If
Next
Set rng2 = sh1.Cells(rw1, 1).End(xlDown)(0)
sh1.Range(sh1.Cells(rw1 + 1, 1), rng2).EntireRow.Delete
Next
End Sub
--
Regards,
Tom Ogilvy
"Paul" wrote:
Hi all
I am making a roster at work and need to print out daily sheets from the
master 4 weekly roster.
master roster (2 days, jack and aimee do not work tue so cells are blank
A B C D E F
name hrs mon locn tue
anna 60 7:30 inside 8:30 l5
jess 50 13:30 l5 9:00 inside
terri 12 12:00 l5 7:30 l5
jack 8 7:30 inside
aimee 8 13:30 l5
New Worksheet
MON
INSIDE
7:30 anna
7:30 jack
l5
12:00 terri
13:30 aimee
13:30 jess
I am such a beginner at excel so any help is greatly appreciated.
|