Pat_The_Bat
Board Regular
- Joined
- Jul 12, 2018
- Messages
- 83
My Sub is putting the date stamp as intended, but then its as if it bails on everything after that point. It's supposed to format the two columns and then delete certain dates based which rows are headers.
Any thoughts why this is happening? Every time I run it, the formatting is never right, and the dates are in the cells where they are supposed to get removed. When I step through the code, it works as intended!!!
Any thoughts why this is happening? Every time I run it, the formatting is never right, and the dates are in the cells where they are supposed to get removed. When I step through the code, it works as intended!!!
Code:
Sub DateStamping()
'This is the Macro that the Time Stamp Button on the Publish Doc List Page operates
Application.ScreenUpdating = False
Dim NewDocs As String
Dim DocStmp As String
Dim NewDate As String
'On Error GoTo Skiptohere2
Sheets("Doc List").Activate
With Sheets("Doc List")
Dim LstRow As Integer
LstRow = Range("F" & .Rows.Count).End(xlUp).Row
Debug.Print LstRow
NewDocs = .Range("F2:F499").SpecialCells(xlConstants).Address
Debug.Print NewDocs
DocStmp = .Range(NewDocs).Offset(, 21).Address
Debug.Print DocStmp
On Error GoTo Skiptohere2
NewDate = .Range(DocStmp).SpecialCells(xlBlanks).Address
Debug.Print NewDate
.Range(DocStmp).Value = "x"
'using address from cprange we move selection left by 25 columns and timestamp
.Range(NewDate).Offset(, -23).Value = Date
Sheets("Doc List").Columns("D:E").NumberFormat = "m/d"
Sheets("Doc List").Columns("D:E").HorizontalAlignment = xlCenter
'>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>DELETE
Dim HDR1 As Range
Dim HDRAK1 As Range
Dim HDR2 As Range
Dim HDRAK2 As Range
Dim HDR3 As Range
Dim HDRAK3 As Range
Dim HDR4 As Range
Dim HDRAK4 As Range
Dim HDR5 As Range
Dim HDRAK5 As Range
Set HDRAK1 = Range("AK:AK").Find("Income")
Debug.Print HDRAK1.Address
Set HDR1 = HDRAK1.Offset(, -33)
Debug.Print HDR1.Address
HDR1.ClearContents
Set HDRAK2 = Range("AK:AK").Find("Asset")
Debug.Print HDRAK2.Address
Set HDR2 = HDRAK2.Offset(, -33)
Debug.Print HDR2.Address
HDR2.ClearContents
Set HDRAK3 = Range("AK:AK").Find("REO")
Debug.Print HDRAK3.Address
Set HDR3 = HDRAK3.Offset(, -33)
Debug.Print HDR3.Address
HDR3.ClearContents
Set HDRAK4 = Range("AK:AK").Find("Credit")
Debug.Print HDRAK4.Address
Set HDR4 = HDRAK4.Offset(, -33)
Debug.Print HDR4.Address
HDR4.ClearContents
Set HDRAK5 = Range("AK:AK").Find("Other")
Debug.Print HDRAK5.Address
Set HDR5 = HDRAK5.Offset(, -33)
Debug.Print HDR5.Address
HDR5.ClearContents
End With
'>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>EndDELETE
GoTo SkiptoEnd
Skiptohere2:
MsgBox "Error"
SkiptoEnd:
End Sub