A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data.
Replace your code with the following. Set was not used to assign ranges to range variables. See bolded text. Defining the function As Range is not essential but it is good programming
Code edited since initial posting to include entering the number in the red cells. Using Cell as a variable is not good because it can be confused with reserved words. I have changed it to rngCell.
Function SelectColoredCells() As Range
Dim sheet As Worksheet
Dim rng As Range
Dim rCell As Range
Dim lColor As Long
Dim rColored As Range
Set sheet = ActiveSheet
sheet.UsedRange.Select
lColor = vbRed
Set rColored = Nothing
For Each rCell In Selection
If rCell.Interior.Color = lColor Then
If rColored Is Nothing Then
Set rColored = rCell
Else
Set rColored = Union(rColored, rCell)
End If
End If
Next
Set SelectColoredCells = rColored
End Function
Sub EnterRooms()
Dim Rooms As Range
Dim rngCell As Range
Dim x As Variant
Set Rooms = SelectColoredCells()
For Each rngCell In Rooms
x = InputBox("Enter Room ID")
rngCell.Value = x 'If the number is to be entered in the red cells
Next rngCell
MsgBox "Finished"
End Sub