Moving between a column's cells
Not totally sure what you are trying to achieve but try getting rid of
the case statement and using:
If NoRoom 150 Then
Cells(CInt(NoRoom) - 147, 1).Select
End If
Hope this helps
Rowan
LoveCandle wrote:
I have created a simple code to reach my goal
Code:
--------------------
Private Sub Worksheet_Change(ByVal Target As Range)
Dim NoRoom As String
If Range("D" & Target.Row).Value 0 Then
NoRoom = InputBox("Enter the room number in the field")
End If
Select Case NoRoom
Case Is = 151
Range("A4").Select
Case Is = 152
Range("A5").Select
Case Is = 153
Range("A6").Select
Case Is = 154
Range("A7").Select
Case Is = 155
Range("A8").Select
Case Is = 156
Range("A9").Select
Case Is = 157
Range("A10").Select
End Select
End Sub
--------------------
but the code will be soooooooo long and it will be very tiring and
time-wasting for me if I enter more than 300 number into it
So my questions a
1- Is there any way to summarize the code and get the same target.
2- When I enter a number in the InputBox's filed which is not available
in column C I want to get a msgbox tells that the number is not
available.
I hope that my question is more obvious now.
Thank you for all in advance
|