Dipmala Patel
Board Regular
- Joined
- Jan 24, 2008
- Messages
- 75
I have following code, but everytime try to run it give me error mess saying "Next Without For". I dont know what am I doing wrong. Thank You.
Sub CopyContractsDemo()
Dim LstRw As Long, _
ContractRng As Range, _
ContractNum As Range, _
ThsSht As String, _
Sht As Worksheet, _
ShtExists As Boolean
Application.ScreenUpdating = False
ActiveSheet.AutoFilterMode = False
ThsSht = ActiveSheet.Name
With Sheets(ThsSht)
LstRw = .Cells(Rows.Count, "A").End(xlUp).Row
'''/// Set the range of contract numbers
Set ContractRng = Range(.Cells(1, "A"), .Cells(LstRw, "A"))
'''/// Loop through each contract number in the contract range
For Each ContractNum In ContractRng
'''/// Skip any blank cells
If IsEmpty(ContractNum) Then
GoTo SkipIt
'''/// Skip Duplicate Contract Numbers
If ContractNum.Row <> 1 Then
If ContractNum.Value = ContractNum.Offset(-1).Value Then
GoTo SkipIt
End If
'''/// If the sheet doesn't exit create one
If Not SheetExists(ContractNum.Value) Then
Sheets.Add After:=Sheets(Sheets.Count)
ActiveSheet.Name = ContractNum.Value
End If
Call BadActor_DrawTable_Heading
'''/// Turn off the Autofilter
.AutoFilterMode = False
SkipIt:
Next ContractNum
End With
'''/// Go bank to the original active sheet
Sheets(ThsSht).Select
Application.ScreenUpdating = True
End Sub