Darren Smith
Well-known Member
- Joined
- Nov 23, 2020
- Messages
- 631
- Office Version
- 2019
- Platform
- Windows
This code says End Without with.
There are 3 With statements & 3 End With statements so why is it saying this?
There are 3 With statements & 3 End With statements so why is it saying this?
VBA Code:
Sub Pre_pro()
Dim Prepro As CommandButton
Dim JCM As Worksheet, PreAssem As Worksheet
Dim Row As Long, lr As Long, preRow As Long
Dim rng As Range, PreProrng As Range, MyCell As Range
Set JCM = ThisWorkbook.Worksheets("Job Card Master")
Set PreAssem = ThisWorkbook.Worksheets("PRE ASSEMBLY3")
Set PreProrng = JCM.Range("M13:M299")
Set Prepro = Body_And_Vehicle_Type_Form.Fill_Details
If Prepro = True Then
With PreAssem
.Cells(1, 7) = JCM.Cells(2, 7)
.Cells(3, 3) = JCM.Cells(8, 1)
.Cells(3, 7) = JCM.Cells(8, 7)
.Cells(5, 3) = JCM.Cells(6, 1) & " " & JCM.Cells(6, 4) & " " & JCM.Cells(6, 5)
.Cells(5, 7) = JCM.Cells(4, 1)
.Cells(7, 3) = JCM.Cells(6, 6)
.Cells(7, 7) = JCM.Cells(4, 4)
.Cells(9, 3) = JCM.Cells(4, 5)
End With
With JCM
lr = .Range("A:K").Find("*", , , , xlByRows, xlPrevious).Row
Set rng = Application.Union(.Range("A13:K61"), _
.Range("A66:K122"), _
.Range("A127:K178"), _
.Range("A188:K244"), _
.Range("A249:K299"), _
.Range("A" & lr & ":" & "K" & lr))
End With
For Each MyCell In PreProrng
If PreProrng Like "*Prepro*" _
Or MyCell Like "*PREPRO*" _
Or MyCell Like "*Preproduction*" _
Or MyCell Like "*Pre-pro*" _
Or MyCell Like "*Pre pro*" Then
preRow = 12
With rng
For Row = 1 To 292
If ((Row >= 1 And Row <= 49) Or (Row >= 53 And Row <= 110) Or (Row >= 114 And Row <= 165) _
Or (Row >= 176 And Row <= 232) Or (Row >= 237 And Row <= 287) Or (Row = 292)) Then
If .Cells(Row, 1) <> "" And .Cells(Row, 3) <> "" And .Cells(Row, 5) <> "" And .Cells(Row, 8) <> "" And .Cells(Row, 11) <> "" Then
PreAssem.Cells(preRow, 1) = .Cells(Row, 1)
PreAssem.Cells(preRow, 2) = .Cells(Row, 3)
PreAssem.Cells(preRow, 3) = .Cells(Row, 5)
PreAssem.Cells(preRow, 4) = .Cells(Row, 8)
PreAssem.Cells(preRow, 5) = .Cells(Row, 11)
preRow = preRow + 1
End If
End If
End If
Next MyCell
End With
End With
End Sub