Jump to content

Welcome to Geeks to Go - Register now for FREE

Need help with your computer or device? Want to learn new tech skills? You're in the right place!
Geeks to Go is a friendly community of tech experts who can solve any problem you have. Just create a free account and post your question. Our volunteers will reply quickly and guide you through the steps. Don't let tech troubles stop you. Join Geeks to Go now and get the support you need!

How it Works Create Account
Photo

How to Save Responses (VBA, Excel)


  • Please log in to reply

#1
beethoven

beethoven

    Member

  • Member
  • PipPip
  • 92 posts
I am a brand new VBA user (ie copied some code off the internet a week ago and am experimenting, so keep it simple please) and I was wondering how to save responses. I have a dialog box that asks your name upon opening the document, and I'd like for that response to be placed in, say, A1. What code would I need? I currently have:

Private Sub CommandButton1_Click()
Dim Response As String
Response = InputBox("What is your name?")
Response = "Your name is " & Response
MsgBox Response
End Sub

If you could help that would be great.

Two days later:
I figured it out by chance after running into other sites online. I will paste my new code should anybody else be helped by it later. Thanks.

Private Sub CommandButton1_Click()
Dim Response As String
Response = InputBox("What is your name?")
Range("A1") = Response
Response = InputBox("Where do you live?")
Range("A2") = Response
Response = InputBox("Please enter your birthdate (MM-DD-YYYY).")
Range("A3") = Response

End Sub

Edited by beethoven, 07 February 2007 - 02:10 PM.

  • 0

Advertisements


#2
dsm

dsm

    Member

  • Member
  • PipPip
  • 98 posts
beethoven,

try this

*************************************
Response = InputBox("What is your name?")
Range("A1").Value = Response

Response = InputBox("Where do you live?")
Range("B1").Value = Response

Response = InputBox("Please enter your birthdate (MM-DD-YYYY).")
Range("C1").Value = Response
*************************************

good luck
dsm
  • 0

#3
beethoven

beethoven

    Member

  • Topic Starter
  • Member
  • PipPip
  • 92 posts
I'm brand new with this so bear with me. What I pasted (final version) works, and it appears yours is about the same thing. What is the difference or how is yours better?
  • 0

#4
dsm

dsm

    Member

  • Member
  • PipPip
  • 98 posts
beethoven,
I misread your original post and assumed the code you pasted did NOT work.
I actually didn't expect your code to work but only because I have always used the more complete syntax.
I just pasted your code and it worked.

Each method is different rather than better.


regards
dsm
  • 0






Similar Topics

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP