Philip1957
Board Regular
- Joined
- Sep 30, 2014
- Messages
- 185
- Office Version
- 365
- Platform
- Windows
Greetings,
I have some code that works, but but now I need to make it loop upwards through the blank cells and stop before overwriting the first non-blank cell. I just can't seem to figure out that whole "i = / Next i" thing.
Also, in the last "Else" statement if the cell (0,-13) from Active is blank I really don't want to write the string "Machine" in it. Is there a way to write an "Else Unless" statement?
Any assistance would be greatly appreciated.
Thank you for your time.
~ Phil
I have some code that works, but but now I need to make it loop upwards through the blank cells and stop before overwriting the first non-blank cell. I just can't seem to figure out that whole "i = / Next i" thing.
Also, in the last "Else" statement if the cell (0,-13) from Active is blank I really don't want to write the string "Machine" in it. Is there a way to write an "Else Unless" statement?
Any assistance would be greatly appreciated.
Code:
Sub Assign_Category()
Dim DfctCode As String
' Select the Data worksheet (Works)
ActiveWorkbook.Sheets("Data").Select
' Find the last Row (Works)
Selection.SpecialCells(xlCellTypeLastCell).Select
' Paste category based on defect code (Works)
DfctCode = ActiveCell.Offset(0, -13)
If InStr(DfctCode, "I") > 0 Then
ActiveCell.Value = "Vendor"
ElseIf InStr(DfctCode, "5") > 0 Or InStr(DfctCode, "22") > 0 _
Or InStr(DfctCode, "26") > 0 Or InStr(DfctCode, "29") > 0 _
Or InStr(DfctCode, "31") > 0 Then
ActiveCell.Value = "Operator"
ElseIf InStr(DfctCode, "I") > 0 Then
ActiveCell.Value = "Vendor"
Else: ActiveCell.Value = "Machine"
End If
End Sub
Thank you for your time.
~ Phil