Hi All!
Have a spreadsheet with a script that was working until a few months ago. The person that wrote the script is no longer with the company and of course the spreadsheet is now being requested as a high priority.
It generates a run time error 13--type mismatch. Here is the code:
Sub Make_Daily_Counts()
Dim objStartSheet As Worksheet
Set objStartSheet = Sheets("Make Daily")
Dim objCountSheet As Worksheet
Set objCountSheet = Sheets("Daily Counts")
Dim currPasteRow As Integer
currPasteRow = 2
For startCurrRow = 2 To objStartSheet.Range("A1").
CurrentReg
ion.Rows.C
ount
Dim objCurrSheet As Worksheet
Dim area As String
area = objStartSheet.Cells(startC
urrRow, 1)
Set objCurrSheet = Sheets("" & objStartSheet.Cells(startC
urrRow, 1))
For currRow = 11 To objCurrSheet.Range("A11").
CurrentReg
ion.Rows.C
ount + 7
Dim weekEnding As Date
weekEnding = objCurrSheet.Cells(currRow
, 1)
Dim startDraw As Long
startDraw = objCurrSheet.Cells(currRow
, 2)
Dim changeWeeklyAmount As Integer
If (area = "Metro") Then
changeWeeklyAmount = objCurrSheet.Cells(currRow
, 14) - objCurrSheet.Cells(currRow
, 21) + objCurrSheet.Cells(currRow
, 26)
Else
changeWeeklyAmount = objCurrSheet.Cells(currRow
, 13) - objCurrSheet.Cells(currRow
, 20) + objCurrSheet.Cells(currRow
, 25)
End If
'Make Daily
Dim currDay As Integer
Dim currDraw As Long
For currDay = 0 To 4
currDraw = Round(startDraw + changeWeeklyAmount * currDay / 5, 0)
objCountSheet.Cells(currPa
steRow, 1) = area
objCountSheet.Cells(currPa
steRow, 2) = weekEnding - 6 + currDay
objCountSheet.Cells(currPa
steRow, 3) = currDraw
currPasteRow = currPasteRow + 1
Next
'Make Saturday and Sunday
If (area = "Metro") Then
currDraw = currDraw - 6000
End If
For currDay = 5 To 6
objCountSheet.Cells(currPa
steRow, 1) = area
objCountSheet.Cells(currPa
steRow, 2) = weekEnding - 6 + currDay
objCountSheet.Cells(currPa
steRow, 3) = currDraw
currPasteRow = currPasteRow + 1
Next
Next
Next
End Sub
Any help would be very appreciated!
spudmcc
Start Free Trial