View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default Can an input box do this

You don't even need to activate the cell first. You can just plop the value
that the user typed right into the cell:

Option Explicit
Sub testme()

Dim myCell As Range
Dim myStr As String

Set myCell = ActiveSheet.Range("C9")

myStr = InputBox(Prompt:="Please enter your name")

If Trim(myStr) = "" Then
Exit Sub 'user hit cancel
End If

myCell.Value = myStr

End Sub

If you're new to macros:

Debra Dalgleish has some notes how to implement macros he
http://www.contextures.com/xlvba01.html

David McRitchie has an intro to macros:
http://www.mvps.org/dmcritchie/excel/getstarted.htm

Ron de Bruin's intro to macros:
http://www.rondebruin.nl/code.htm

(General, Regular and Standard modules all describe the same thing.)


Munchkin wrote:

Can a macro button activate a cell, then have an an input box pop up that
asks a user to enter their name, and upon doing so & clicking OK place the
name in the activaed cell?

I'm self taught at Visual Basics & can't figure how to do this. Am I
misunderstanding input boxes - or can an input box do this, and if so, how?


--

Dave Peterson