?
Solved

Excel vb script Error

Posted on 2013-06-05
4
Medium Priority
?
243 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 2000 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

This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Ever wonder what it's like to get hit by ransomware? "Tom" gives you all the dirty details first-hand – and conveys the hard lessons his company learned in the aftermath.
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

800 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