New to Visual Basic

  • Thread starter Thread starter Need help with sumif
  • Start date Start date
N

Need help with sumif

I wrote this simple task can anyone tell me how do I run this

Private Sub CommandButton1_Click()
Dim sName As String
sName = InputBox("Enter your name", "Title")
Cells.Value("A1") = sName
End Sub
 
Hi,

A couple of syntax errors. This type of button is from the 'Control' toolbox
so with the syntax corrected simply click the button. the button must be out
of design mode. Click the icon that looks like a set-square to exit design
mode.

Private Sub CommandButton1_Click()
Dim sName As String
sName = InputBox("Enter your name", "Title")
Range("A1").Value = sName
End Sub


Mike
 
First, remove the private from your macro, since you want to call it out via
a button (I assume).

Also, "Cells.Value("A1") = sName" is not valid. Change it to:
Cells(1,1).Value = sName

Using the Forms toolbar (NOT control), create a button. Then assign your
macro to the button.
 
Back
Top