inputbox function

  • Thread starter Thread starter nhanh
  • Start date Start date
N

nhanh

Hi,

I am really new to VBA programming and was seeking some help and thi
seems like a great place to do it.

Here is the code that i have at the moment:


Public Sub AddNames()

Dim FirstName As String
FirstName = InputBox("What is your firstname?", "First Name")
ActiveWorkbook.Worksheets("sheet1").Range("B2").Value
_\"=FirstName_"

End Sub


My aim is to get an input box to prompt a user to input their firs
name and after the user does so, excel will input the user's name int
the particular cell. I think my problem is what i've underline
("=FirstName")... i don't know what i should put after the value to ge
it to do what i need it to do. Maybe i've made other mistakes too?

Any help would be great. Thanks
 
It was a simple mistake you made.....try this....

Public Sub AddNames()

Dim FirstName As String
FirstName = InputBox("What is your firstname?", "First Name")
ActiveWorkbook.Worksheets("sheet1").Range("B2").Value = FirstName

End Sub

Note i have removed the " from both ends and the = as formulae o
answers to arguments have =, you have already declared Firstname.

Hope this helps.

Simo
 
Public Sub AddNames()

Dim FirstName As String
Do
FirstName = InputBox("What is your firstname?", "First Name")
ActiveWorkbook.Worksheets("sheet1").Range("B2").Value =FirstName
loop until FirstName <> ""

End Sub
 
Nice Bob!,

Wish i had thought of the lines you added.......Do.....loop unti
FirstName <> ""


Simo
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top