Jump to content

Welcome to Geeks to Go - Register now for FREE

Geeks To Go is a helpful hub, where thousands of volunteer geeks quickly serve friendly answers and support. Check out the forums and get free advice from the experts. Register now to gain access to all of our features, it's FREE and only takes one minute. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more.

Create Account How it Works
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