Good Evening
I have a slight problem with the code below. I want to check first that the cell selected is within a given range of columns (7 to 12). If not, I want to exit the while loop. I put in the msgboxes to try and work out why it was doing so. If I selected a cell in column 5, it carried on regardless. For information, the second valid=false seems to behave.
Any ideas?
Incidentally, the last line I am also struggling with. I want to refresh the combo box after this function has been called, but it keeps saying object required.
Thanks
Chris
I have a slight problem with the code below. I want to check first that the cell selected is within a given range of columns (7 to 12). If not, I want to exit the while loop. I put in the msgboxes to try and work out why it was doing so. If I selected a cell in column 5, it carried on regardless. For information, the second valid=false seems to behave.
Any ideas?
Incidentally, the last line I am also struggling with. I want to refresh the combo box after this function has been called, but it keeps saying object required.
Thanks
Chris
Code:
While Valid = True
'Check if column is valid
If CellCount.Column < 7 Or CellCount.Column > 12 Then
MsgBox ("Confirmed out of limits")
Valid = False
MsgBox ("yet got beyond valid=false")
End If
MsgBox (CellCount.Column)
'Work out what row we're in
If Cells(CellCount.row, 5) = "On" Then
RowNumber = CellCount.row + 4
Else
If Cells(CellCount.row, 5) = "Off" Then
RowNumber = CellCount.row + 3
Else
If Cells(CellCount.row, 5) = "Worked" Then
RowNumber = CellCount.row + 2
Else
If Cells(CellCount.row, 5) = "Notes" Then
RowNumber = CellCount.row + 1
Else
If Cells(CellCount.row - 1, 5) = "Notes" Then
RowNumber = CellCount.row
Else
Valid = False
End If
End If
End If
End If
End If
If InStr(Cells(RowNumber - 1, CellCount.Column), "RD") > 0 Then
Cells(RowNumber - 4, CellCount.Column) = ""
Else
Cells(RowNumber - 4, CellCount.Column) = ""
Cells(RowNumber, CellCount.Column) = Sheets("SAP Codes").Cells(RowCount, 3) & Chr(10) & "(" & SAPCode & ")"
End If
Valid = False
Wend
Next
'MyRibbon.Invalidate ("cboSAPCodes")