Input Boxes Help

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
Code:
Sub Confirm()
' Guest Confirmation'

Dim rngName As Range, intResponse
    Dim strName As String
    If Intersect(Selection, Range("B3:Ae14")) Is Nothing Then Exit Sub

    If Selection.Rows.Count > 1 Then
   MsgBox "Please Select 1 Room Only", 0, "Booking Error"
   Exit Sub
End If
If Application.CountA(Selection) <> 0 Then
                MsgBox "The 1 Or More Night(s) That You Have Selected Have Already Been Taken", 0, "Booking Error"

        Exit Sub
    End If

    
    strName = InputBox("Please Enter Guest Names", "Peverel Hall Hotel - Guest Confirmation", Default:="Enter Guest Name Here")
    
    On Error Resume Next
    Set rngName = Range(strName)
    If Err.Number = 0 Then          ' no error, name already exists
    MsgBox "You Have Made A Error While Entering Data." & vbCr & vbCr & _
           "The Name You Have Enter Already Exist Please Enter A Different Name.", _
           vbExclamation, "Naming Conflict"
    Exit Sub
End If

    
    On Error GoTo handler
    ActiveWorkbook.Names.Add Name:=strName, RefersTo:=Selection
    Selection.Interior.ColorIndex = 4
    Selection.FormulaR1C1 = "C"
    
handler:
        If Err.Number = 1004 Then
            MsgBox "You Have Made A Error While Entering Data. Below Is A List Of Possible Errors" & vbCr & "" & vbCr & "1.You Have Entered No Data" & vbCr & "2.You Have Enterd More Than 1 Word", 0, "Error"
        End If
    
   

End Sub

i have this so it turn the cell green and enters a c but i want la list os if it is a c turn the cells grenn and enter a c in them and if it is r turn the cells red and enter a r in the cells
 
Upvote 0
This code will give you an input box. The result of that input box will change the active cell to Red or Green with either an R or a C.

Code:
Sub newConfirm()
myinput = InputBox("Please Enter a C or an R", "Input")
If myinput = "C" Then
    ActiveCell = myinput
    ActiveCell.Interior.ColorIndex = 4
    
ElseIf myinput = "R" Then
    ActiveCellR = myinput
    ActiveCell.Interior.ColorIndex = 3
Else
    MsgBox "You did not enter a C or an R"
End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,225,137
Messages
6,183,078
Members
453,146
Latest member
Lacey D

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top