Solved

Excel vb script Error

Posted on 2013-06-05
4
232 Views
Last Modified: 2013-06-06
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
0
Comment
Question by:CodyPorter
  • 2
4 Comments
 
LVL 26

Accepted Solution

by:
redmondb earned 500 total points
ID: 39224204
Hi, CodyPorter.

Yes, just replace...
Set ShRange = .Range("C7:C" & ShLastRow)

Open in new window

...by...
Set ShRange = .Range("C8:C" & ShLastRow)

Open in new window

Regards,
Brian.
0
 

Author Comment

by:CodyPorter
ID: 39227208
That worked perfectly!  Thank you.  Is that because someone added row 7?
0
 
LVL 26

Expert Comment

by:redmondb
ID: 39227425
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.
0

Featured Post

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Using Word 2013, I was experiencing some incredible lag when typing.  Here's what worked for me....
My experience with Windows 10 over a one year period and suggestions for smooth operation
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now