Message box data to next line

john0207

New Member
Joined
Apr 27, 2008
Messages
5
Hi I have this code for a workbook I have been trying to make, the problem is I need the next time a question is answered to have the data appear on the next empty cells in that column

Code:
Sub SAVE_INPUT_BOX()
MY_ENTRY = InputBox("Enter Your Name", "Name")
Range("Sheet2!a1").Value = MY_ENTRY
MY_ENTRY = InputBox("Please Vote 'N' for no, 'Y' fro yes or 'A' to abstain", "Vote Now")
Range("Sheet2!b1").Value = MY_ENTRY
MsgBox "Thank You For Voting, Your Vote has been Registered"
ThisWorkbook.Save
 
End Sub

is this possible or should I look at achieving this another way.

many thanks
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
Hi,
welcome to forum.

try this update to your code & see if does what you want

Code:
Sub SAVE_INPUT_BOX()
    Dim MY_ENTRY(1 To 2) As Variant
    Dim rng As Range
    Dim i As Integer
    
'next row
    Set rng = Sheet2.Cells(Sheet2.Cells(Sheet2.Rows.Count, "A").End(xlUp).Row + 1, 1)
'array index counter
    i = 1
    Do
        MY_ENTRY(i) = InputBox(Choose(i, "Enter Your Name", _
                                        "Please Vote 'N' for no, 'Y' for yes or 'A' to abstain"), _
                                        Choose(i, "Name", "Vote Now"))
'cancel pressed
        If StrPtr(MY_ENTRY(i)) = 0 Then Exit Sub
    
        If Len(MY_ENTRY(i)) > 0 Then
'ensure Y, N, A responses Upper Case
            If i = 2 Then MY_ENTRY(i) = UCase(MY_ENTRY(i))
'name or Y, N, A entered
            If Not IsError(Application.Match(MY_ENTRY(i), Array("Y", "N", "A"), False)) Or i = 1 Then i = i + 1
        End If
    Loop Until i > 2


'send to worksheet
    rng.Resize(, 2).Value = MY_ENTRY
'inform user
    MsgBox "Thank You For Voting, Your Vote has been Registered", 64, "Vote Registered"
'save
    ThisWorkbook.Save
 
End Sub

I included some response checking your Y, N, A values & ensured these are posted to your worksheet in upper case.
As suggestion, you could include date / time stamp when users vote.

Hope helpful

Dave
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,183
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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