S
sa3214
Can anyone tell me where I am going wrong with this code:
With Sheets(SheetName)
.Range("M2:U34").ClearContents
.Range("AA2:AC65536").ClearContents
.Range("V2") = Format(DateBox, "Long Date")
.Columns("A:J").AdvancedFilter Action:=xlFilterCopy,
CriteriaRange:=.Range( _
"V1:V2"), CopyToRange:=.Columns("AA:AC"), Unique:=False
LastBooking = .Range("AA65536").End(xlUp).Row
For b = 2 To LastBooking
' .... NEXT LINE causes Error 91
RowNo = .Range("L2:L34").Find(.Cells(b, 27)).Row
If .Cells(b, 28) = "Yes" Then
c = 17
Else
c = 14
End If
For r = 0 To 7
.Cells(RowNo + r, c) = .Cells(RowNo + r, c) + .Cells(b, 27)
Next r
Next b
If TimeBox <> "" And Seats <> "" Then
ProvRowNo = .Range("L2:L34").Find(Format(TimeBox, "hh:mm")).Row
If Smoking = True Then
c = 16
Else
c = 13
End If
For r = 0 To 7
.Cells(ProvRowNo + r, c) = Format(Seats, "##0")
Next r
End If
End With
Regards and TIA
Jim Burton
With Sheets(SheetName)
.Range("M2:U34").ClearContents
.Range("AA2:AC65536").ClearContents
.Range("V2") = Format(DateBox, "Long Date")
.Columns("A:J").AdvancedFilter Action:=xlFilterCopy,
CriteriaRange:=.Range( _
"V1:V2"), CopyToRange:=.Columns("AA:AC"), Unique:=False
LastBooking = .Range("AA65536").End(xlUp).Row
For b = 2 To LastBooking
' .... NEXT LINE causes Error 91
RowNo = .Range("L2:L34").Find(.Cells(b, 27)).Row
If .Cells(b, 28) = "Yes" Then
c = 17
Else
c = 14
End If
For r = 0 To 7
.Cells(RowNo + r, c) = .Cells(RowNo + r, c) + .Cells(b, 27)
Next r
Next b
If TimeBox <> "" And Seats <> "" Then
ProvRowNo = .Range("L2:L34").Find(Format(TimeBox, "hh:mm")).Row
If Smoking = True Then
c = 16
Else
c = 13
End If
For r = 0 To 7
.Cells(ProvRowNo + r, c) = Format(Seats, "##0")
Next r
End If
End With
Regards and TIA
Jim Burton