+ Reply to Thread
Results 1 to 7 of 7

Using an InputBox to populate a cell

  1. #1
    Forum Contributor
    Join Date
    08-14-2006
    Location
    USA
    MS-Off Ver
    2019
    Posts
    686

    Using an InputBox to populate a cell

    This line doesn't work:
    ActiveCell.Value = InputBox("What is the New Entry?")

    This line does work but I can't use it:
    Range("A30").Value = InputBox("What is the New Entry?")
    Problem is, I don't actually know the cell address, I'm using preceding code to find the cell I want.

    Please Login or Register  to view this content.
    What is my problem?
    TIA

  2. #2
    Forum Expert
    Join Date
    12-29-2004
    Location
    Michigan, USA
    MS-Off Ver
    2013
    Posts
    2,208
    Try assigning a variable to the inputbox, then transferring the variable to the cell:
    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    08-14-2006
    Location
    USA
    MS-Off Ver
    2019
    Posts
    686
    Thanks, but it still won't put the data in the cell.

  4. #4
    Forum Expert
    Join Date
    12-29-2004
    Location
    Michigan, USA
    MS-Off Ver
    2013
    Posts
    2,208
    Is the sheet protected? Do you receive any kind of either Excel or VBA error? Does any VBA code overwrite/delete this active cell? Both your and my code above should work, so something is amiss.

  5. #5
    Forum Contributor
    Join Date
    08-14-2006
    Location
    USA
    MS-Off Ver
    2019
    Posts
    686
    1. the sheet is not protected
    2. it does select the last blank cell in the column (which happens to be A30)
    3. by putting Range("A30").Value = "TEST" in the Immediate Window, I can force data into cell A30.

    4. I get no error messages
    5. however, the visible window when the macro is finished is the VBA window NOT the spreadsheet ???

  6. #6
    Forum Expert Simon Lloyd's Avatar
    Join Date
    03-02-2004
    Location
    locked in the cage
    MS-Off Ver
    All the ones my homepage shows
    Posts
    3,161
    Try this:
    Please Login or Register  to view this content.
    regards,
    Simon

  7. #7
    Forum Contributor
    Join Date
    08-14-2006
    Location
    USA
    MS-Off Ver
    2019
    Posts
    686

    Found It!

    I had a Private Sub Worksheet_Change(ByVal Target As Range)

    that was changing the entry to blank.

    stepping through it showed me that!

    Sorry for the trouble.

    How does one keep straight all the codes you've written.
    Especially when you're jumping back and forth between multiple projects all day?

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1