#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 10
Default New to Visual Basic

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



  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,420
Default New to Visual Basic

You add a button to the worksheet and call it CommandButton1. Then you click
it.

--
__________________________________
HTH

Bob

"Need help with sumif" wrote
in message ...
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





  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,501
Default New to Visual Basic

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


"Need help with sumif" wrote:

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



  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,722
Default New to Visual Basic

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.
--
Best Regards,

Luke M
*Remember to click "yes" if this post helped you!*


"Need help with sumif" wrote:

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



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Visual Basic mcp201 Excel Discussion (Misc queries) 0 June 23rd 08 06:05 PM
In visual basic Chuck Excel Worksheet Functions 5 December 30th 07 04:08 PM
visual basic Matthew Excel Discussion (Misc queries) 4 October 10th 07 02:28 PM
changing the visual basic in office 2003 to visual studio net bigdaddy3 Excel Discussion (Misc queries) 1 September 13th 05 11:57 AM
Visual Basic Micos3 Excel Discussion (Misc queries) 9 June 28th 05 02:41 PM


All times are GMT +1. The time now is 04:54 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"