Pat_The_Bat
Board Regular
- Joined
- Jul 12, 2018
- Messages
- 83
This macro is supposed to place an "x" in column z once a row has been copied and pasted, so that I can add items to the list without re-adding all the items on the list. When I step through the code, I watch the x get placed in column Z. But for some reason, when I run it from the button on the sheet in the wkbk, it doesn't work. The button is on a different sheet, so I thought maybe that was why, but the code specifically says "With this sheet, do this thing"
Code:
Sub GeneratePublish()
Worksheets("Doc Checklist").Visible = True
Dim LstRow As Integer
Dim dcol As String 'variable to find row range to analyze column Z for marks
Dim CpRange As String 'variable to find those rows which haven't been already copied
Dim Zcol As String
Sheets("Doc Checklist").Visible = True
With Worksheets("Doc Checklist")
LstRow = .Range("D" & .Rows.Count).End(xlUp).Row
End With
Debug.Print LstRow
With Worksheets("Doc Checklist")
On Error Resume Next
dcol = .Range("D2:D500").SpecialCells(xlConstants).Address
Debug.Print dcol
Zcol = .Range(dcol).Offset(, 22).Address
Debug.Print Zcol
On Error GoTo NoDocsToAdd
CpRange = .Range(Zcol).SpecialCells(xlBlanks).Address
Debug.Print CpRange
.Range(CpRange).Offset(, -22).EntireRow.Copy
Range(CpRange).Value = "x"
MsgBox "Docs are Prepared for Publishing"
End With
'*************************************************************************************************************************
Dim LstRow2 As Integer
With Sheets("Publish Doc List")
LstRow2 = .Range("D" & .Rows.Count).End(xlUp).Row
Debug.Print LstRow2
Worksheets("Publish Doc List").Range("A" & LstRow2 + 1).PasteSpecial xlPasteValues
Application.CutCopyMode = False
Worksheets("Publish Doc List").Activate
Worksheets("Publish Doc List").Range("A1").Value = "x"
Worksheets("Publish Doc List").Range("A1").Select
End With
Call InsertCats2
'Call DateStamping
GoTo SkipToFinish
NoDocsToAdd:
Sheets("Doc Checklist").Visible = False
Worksheets("Publish Doc List").Activate
Range("A20").Select
MsgBox "No Docs To Add"
SkipToFinish:
On Error Resume Next
Sheets("Publish Doc List").Range("D2:D499").SpecialCells(xlBlanks).EntireRow.Delete
On Error GoTo 0
Sheets("Doc Checklist").Visible = False
Worksheets("Publish Doc List").Activate
Range("A20").Select
MsgBox "Doc List is ready to Publish"
End Sub