Simple Inputbox

Chewyhairball

Board Regular
Joined
Nov 30, 2017
Messages
97
Hi

How do you get the following code to enter the data into the current selected cell instead of having to define a specific cell.? I am just looking

Dim i As Variant
i = InputBox("Please Enter Your Name", "Personal Information", "Type Here")
Range("A1").Value = i
End Sub
 

Some videos you may like

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.

dmt32

Well-known Member
Joined
Jul 3, 2012
Messages
6,387
Office Version
  1. 2019
Platform
  1. Windows
Hi

try

Rich (BB code):
Dim i As Variant
    i = InputBox("Please Enter Your Name", "Personal Information", "Type Here")
    ActiveCell.Value = i

Dave
 

Chewyhairball

Board Regular
Joined
Nov 30, 2017
Messages
97
Dim i As Variant i = InputBox("Please Enter Your Name", "Personal Information", "Type Here") ActiveCell.Value = i

What!!! that was the first thing I tried ( or I thought it was) and it didn't work. I thought it was that simple. I must have typed something wrong or I am losing the plot today.
Thanks very much DMT. :)
 

dmt32

Well-known Member
Joined
Jul 3, 2012
Messages
6,387
Office Version
  1. 2019
Platform
  1. Windows
you are welcome

If you want to add a little more functionality to your code

VBA Code:
Dim i As Variant
    Do
    i = InputBox("Please Enter Your Name", "Personal Information", "Type Here")
    'cancel pressed
    If StrPtr(i) = 0 Then Exit Sub
    Loop Until Len(i) > 0 And i <> "Type Here"
    ActiveCell.Value = i

Dave
 
Last edited:

Watch MrExcel Video

Forum statistics

Threads
1,123,259
Messages
5,600,575
Members
414,390
Latest member
plimbu

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
Top