My code is constantly being interrupted for no reason in random spots. It's almost as if I'm constantly pressing ctrl-break (which I'm not) I ran it through once flawlessly. Now, it's another story. I can't make any sense of this... very frustrating.
I could make a microsoft bashing remark right now, but I'm not going to. (thank goodness I have a mac at home)
Also, if the code isn't interrupted my excel.range object doesn't get its assigned range and the macro stops as a result.
Here's my code. Any thoughts would be great! Thank You.
I could make a microsoft bashing remark right now, but I'm not going to. (thank goodness I have a mac at home)
Also, if the code isn't interrupted my excel.range object doesn't get its assigned range and the macro stops as a result.
Here's my code. Any thoughts would be great! Thank You.
Code:
Sub Classifier()
strComplexPath = "C:\Documents and Settings\U771009\Desktop\"
strFileName = "ComputerClassifications.xls"
strFullPath = strComplexPath & strFileName
Columns("C:C").Select
Selection.Insert Shift:=xlToRight
Range("C1").Select
ActiveCell.FormulaR1C1 = "Classification"
Columns("C:C").ColumnWidth = 16.71
Dim xlRange As Excel.Range
Dim xlRange2 As Excel.Range
Dim strToFind As String
Dim strColumn As String
Dim strClassification As String
Dim strUnknowns(100) As String
Dim intUnknCnt As Integer
Dim intCounter As Integer
Dim intCount2 As Integer
'Go through Products
For intCounter = 1 To 10000
'This is where the range loses its value occasionally.
Set xlRange = Range("B" & intCounter)
xlRange.Select
If ActiveCell.FormulaR1C1 = "" Then
Exit For
End If
If (InStr(xlRange.Text, "Bulk") > 0) Then
strToFind = xlRange.Value
strToFind = ParseOut(strToFind)
Workbooks("ComputerClassifications.xls").Activate
strColumn = "A"
strClassification = ""
For intCounter2 = 1 To 500
Set xlRange2 = Range(strColumn & intCounter2)
If xlRange2.Text = "" Then
strColumn = NextColumn(strColumn)
intCounter2 = 1
If strColumn <> "" Then
Set xlRange2 = Range(strColumn & intCounter2)
Else
Exit For
End If
End If
If intCounter2 = 1 Then
If xlRange2.Text = "" Then
Exit For
End If
End If
If strToFind = xlRange2.FormulaR1C1 Then
strClassification = Range(strColumn & 1)
Exit For
End If
Next
If strClassification = "" Then
strUnknowns(intUnknCnt) = strToFind
intUnknCnt = intUnknCnt + 1
Else
Workbooks("OrdStat.xls").Activate
Range("C" & intCounter).FormulaR1C1 = strClassification
End If
Else
'If intCounter <> 1 Then
'Rows(CStr(intCounter) & ":" & CStr(intCounter)).Select
'Range("B" & CStr(intCounter)).Activate
'Selection.Delete Shift:=xlUp
'End If
End If
Next
If intUnknCnt > 0 Then
Dim strMsg As String
For intCount = 0 To intUnknCnt
strMsg = strMsg & strUnknowns(intCount) & vbLf
Next
MsgBox ("Some Products could not be classified. Please find the appropriate classification." & _
strMsg)
End If
End Sub