Solved

Excel vb script Error

Posted on 2013-06-05
4
241 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Office 365 Training for IT Pros

Learn how to provision tenants, synchronize on-premise Active Directory, implement Single Sign-On, customize Office deployment, and protect your organization with eDiscovery and DLP policies.  Only from Platform Scholar.

Question has a verified solution.

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

Microsoft Office Picture Manager was included in Office 2003, 2007, and 2010, but not in Office 2013. Users had hopes that it would be in Office 2016/Office 365, but it is not. Fortunately, the same zero-cost technique that works to install it with …
Outlook for dependable use in a very small business   This article is about using the Outlook application (part of Microsoft Office) in a very small business, or for homeowners where dependability and reliability are critical requirements. This …
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

717 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