CodyPorter
asked on
Excel vb script Error
I am getting a mis-match error in a script that was written by someone else. I'm not familiar with the spreadsheet, but I am thinking it's a simple fix. . .
Here is the code
Sub TwoMonthsSurveyDue() '2 Month Warning for Survey Date
Dim sApprovalStatus As String
Application.Calculation = xlCalculationManual
iSht = "1"
With Sheets(iSht)
ShLastRow = .Cells(Rows.Count, "C").End(xlUp).Row
Set ShRange = .Range("C7:C" & ShLastRow)
End With
For Each ShCell In ShRange 'get data from sheet(1)
sApprovalStatus = ShCell.Offset(0, 7).Value
If DateDiff("d", ShCell, Now) >= -60 Then
ShCell.Select
'MsgBox DateDiff("d", ShCell, Now) & " @ Row " & ShCell.Row 'for testing
ShCell.Offset(0, 7).Value = "Due Date"
Else
'MsgBox DateDiff("d", ShCell, Now) & " @ Row " & ShCell.Row & " " & sApprovalStatus 'for testing
If sApprovalStatus = "Due Date" Then
ShCell.Offset(0, 7).Value = "Approved"
Else
ShCell.Offset(0, 7).Value = sApprovalStatus
End If
End If
Next ShCell
Range("A7").Select
Application.Calculation = xlCalculationAutomatic
End Sub
(Edit: Both attachments redacted - Modulus Twelve)
Copy-of-Approved-Supplier-List-R.xlsm
Doc1-Redacted.docx
Here is the code
Sub TwoMonthsSurveyDue() '2 Month Warning for Survey Date
Dim sApprovalStatus As String
Application.Calculation = xlCalculationManual
iSht = "1"
With Sheets(iSht)
ShLastRow = .Cells(Rows.Count, "C").End(xlUp).Row
Set ShRange = .Range("C7:C" & ShLastRow)
End With
For Each ShCell In ShRange 'get data from sheet(1)
sApprovalStatus = ShCell.Offset(0, 7).Value
If DateDiff("d", ShCell, Now) >= -60 Then
ShCell.Select
'MsgBox DateDiff("d", ShCell, Now) & " @ Row " & ShCell.Row 'for testing
ShCell.Offset(0, 7).Value = "Due Date"
Else
'MsgBox DateDiff("d", ShCell, Now) & " @ Row " & ShCell.Row & " " & sApprovalStatus 'for testing
If sApprovalStatus = "Due Date" Then
ShCell.Offset(0, 7).Value = "Approved"
Else
ShCell.Offset(0, 7).Value = sApprovalStatus
End If
End If
Next ShCell
Range("A7").Select
Application.Calculation = xlCalculationAutomatic
End Sub
(Edit: Both attachments redacted - Modulus Twelve)
Copy-of-Approved-Supplier-List-R.xlsm
Doc1-Redacted.docx
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Thanks, CodyPorter.
Is that because someone added row 7?
Possibly. Or it could be because on of Rows 1 to 5 were inserted.
I've just noticed the emails, phone numbers, contacts etc. If they are real then that file needs to be redacted. Please let me if that's the case and I'll take care of it.
Is that because someone added row 7?
Possibly. Or it could be because on of Rows 1 to 5 were inserted.
I've just noticed the emails, phone numbers, contacts etc. If they are real then that file needs to be redacted. Please let me if that's the case and I'll take care of it.
ASKER