Solved

Excel vb script Error

Posted on 2013-06-05
4
236 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.
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.

726 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