I have an array that is created by loading a range from a workbook into a variant. When I try and validate the data (by checking if it matches either of two strings - see commented error line below) in the array globaldataarray I get "Run Time Error '13' Type mismatch".
The column of data in question has a column heading (excluded by starting at row 2) and according to the quick pivot table I ran on it, to see the unique entries, contained only blanks, single letters and 3 letter strings.
I get the same error when trying to do the same thing on a column of numbers (decimal an integer) produced by a formula in that column.
Any ideas thoughts or suggestions much appreciated.
Code
Option Explicit
Option Base 1
Public Sub ocalc()
Dim formulastore As String
Dim startcell, firstcellrange, fullrange As String
Dim sourcedatarange As Range
Dim loopglobaldata As Long
Dim i As Long
Dim j As Long
Dim newarraysize As Long
Dim newarray As Variant
firstcellrange = "V11"
fullrange = "V11:AI35"
'Worksheets("Parameters").Range("R11:R110").Calculate
'Worksheets("Parameters").Range("A11:D35").Calculate
Sheets("48_sheet4").Activate
Set sourcedatarange = Sheets("48_Sheet4").Range(Cells(2, 1), Cells(Range("A65536").End(xlUp).row, 31))
Sheets("parameters").Activate
Application.ScreenUpdating = False
ActiveWorkbook.PrecisionAsDisplayed = False
startcell = activecell.Address
formulastore = Range(firstcellrange).Formula
Range(fullrange).ClearContents
With Application
.Calculation = xlAutomatic
.MaxChange = 0.001
End With
'// Load date once sheet updated.
Call loaddata(sourcedatarange)
With Range(firstcellrange)
.Formula = formulastore
.Copy
End With
If Sheets("Parameters").Range("H6").Value = 0 Then
For loopglobaldata = 1 To UBound(globaldataarray, 1)
Debug.Print globaldataarray(loopglobaldata, 30)
If globaldataarray(loopglobaldata, 30) = "OHS" Or "DHS" Then '// <-------Error here.
For i = LBound(globaldataarray, 2) To UBound(globaldataarray, 2)
globaldataarray(loopglobaldata, i) = ""
Next i
End If
Next loopglobaldata
End If
'///..............
Display More
In a separate module;