Command button prompt to input 2 columns of data

Cazzdevil

New Member
Joined
Jul 18, 2014
Messages
10
Hi all! :)

Following some great help from a forum member last night, my new Time in Motion sheet is coming along nicely with some snazzy programmed Command Buttons to fill data into another sheet.

One of my buttons is for 'other' tasks, so I'd like to programme a button to prompt first for a number of minutes (e.g. 30), and then a brief description (e.g. Meeting) and input the data side-by-side in 2 columns on sheet 2.

This is what I have for my other single-entry buttons, so what would I need to add?

Dim ans As String
ans = InputBox("Case reference:", "Data Entry")
Sheets("Sheet2").Range("F" & Sheets("Sheet2").Range("F" & Rows.Count).End(xlUp).Row + 1).Value = ans

Much appreciated xx
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
Cazzdevil (aka Excel geek)

Two ways to do it. Simple quick one but is lesser user experience

Code:
Dim ans1, ans2 As String

' two input boxes to get both answers
ans1 = InputBox("Number of minutes:", "Data Entry")
ans2 = InputBox("Brief Description:", "Data Entry")

'Get the next available row number based on column A
nNextAvailableRow = Sheets("Sheet3").Range("A" & Rows.Count).End(xlUp).Row + 1

'Cells is based on Cells(Row,Column) so the column reference wouold be the appropraite column number eg A = 1, B = 2
Sheets("Sheet3").Cells(nNextAvailableRow, 1) = ans1
Sheets("Sheet3").Cells(nNextAvailableRow, 2) = ans2


Better way would be to use a UserForm with two text boxes for the user to complete at one time

In that scenario you would replace ans1 and ans2 with UserForm1.Textbox1.Value and UserForm1.TextBox2.Value
 
Upvote 0

Forum statistics

Threads
1,215,223
Messages
6,123,711
Members
449,118
Latest member
MichealRed

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