mockturtle29
New Member
- Joined
- May 16, 2013
- Messages
- 6
I'm trying to enter corresponding part numbers, and I keep getting a Type Mismatch error. The part number in column B corresponds to a part number to be entered in column B. I've hard-coded the numbers and included a couple of the loops here. I want it to go through the CurrentRegion because not every report has the same number of rows. This code works if I change the "For" to be "For row = 1 to 75", but I don't want to limit it to 75 rows.
Here is my code:
For Each row In ActiveCell.CurrentRegion.Cells
If Cells(row, 2) = "3038628" Then ' This is where it fails and gives the Type Mismatch error.
Cells(row, 1) = "88042-1"
End If
If Cells(row, 2) = "3072850-01" Then
Cells(row, 1) = "94977-1"
End If
Next row
I think I've got to change how it calls the cell, but I'm a VBA neophyte and am not sure how to change it. Any assistance would be appreciated!
Thank you in advance
Here is my code:
For Each row In ActiveCell.CurrentRegion.Cells
If Cells(row, 2) = "3038628" Then ' This is where it fails and gives the Type Mismatch error.
Cells(row, 1) = "88042-1"
End If
If Cells(row, 2) = "3072850-01" Then
Cells(row, 1) = "94977-1"
End If
Next row
I think I've got to change how it calls the cell, but I'm a VBA neophyte and am not sure how to change it. Any assistance would be appreciated!
Thank you in advance