I have created a part of my addin to allow users to add product information to a spreadsheet without typing them all in, all they need to type in is the product code. I am trying to make the addin more intuitive by guessing what column holds the product code which would be a six digit numeral with no decimals and is always positive. This is what I have so far:
[VBA]If Len(ActiveCell.Offset(, -1)) = 6 Then
frmExtraAddTo.sbColDiff.Value = -1
ElseIf Len(ActiveCell.Offset(, -2)) = 6 Then
frmExtraAddTo.sbColDiff.Value = -2
ElseIf Len(ActiveCell.Offset(, -3)) = 6 Then
frmExtraAddTo.sbColDiff.Value = -3
ElseIf Len(ActiveCell.Offset(, -4)) = 6 Then
frmExtraAddTo.sbColDiff.Value = -4
ElseIf Len(ActiveCell.Offset(, -5)) = 6 Then
frmExtraAddTo.sbColDiff.Value = -5
ElseIf Len(ActiveCell.Offset(, -3)) = 6 Then
frmExtraAddTo.sbColDiff.Value = -6
ElseIf Len(ActiveCell.Offset(, -6)) = 6 Then
frmExtraAddTo.sbColDiff.Value = -3
ElseIf Len(ActiveCell.Offset(, -7)) = 6 Then
frmExtraAddTo.sbColDiff.Value = -7
ElseIf Len(ActiveCell.Offset(, -8)) = 6 Then
frmExtraAddTo.sbColDiff.Value = -8
ElseIf Len(ActiveCell.Offset(, -9)) = 6 Then
frmExtraAddTo.sbColDiff.Value = -9
ElseIf Len(ActiveCell.Offset(, -10)) = 6 Then
frmExtraAddTo.sbColDiff.Value = -10
End If[/VBA]
it works correctly but I also want it to test if it is a number and no decimal. Checking if it is positive is easy. Also, I will change this into a loop after I get it working.