Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1
Default Command Button to store a value in Excel/VBA.......


Hi,

All I need is to know how to use a command button in vba to store a
value in a cell in Excel.

I have a user form with two command buttons on it. one button is
labeled, "Test1", the other labeled, "Test2."

When the user clicks on the button labeled, "Test1", I want the word,
"Test1" to appear in the next available cell in row, "A." When the
user clicks onk, "Test2", I want the word, "Test2" to appear in the
next available cell in row, "A."

I want it set up so that every time the user clicks on either button,
it stores the value in the next available row without replacing the
exiisting value that is in the cell. So say the user clicks on the,
"Test1CommandButton", it stores, "Test1" in, "A1." And the next time
they click the, "Test1(or Test2)CommandButton", it stores, "Test1"(or,
"Test2"), in, "A2", ect..........Thats it.

I'm guessing the code is something like the following.......

Test1CommandButton Click()
Sheet("Sheet1").Range("A" & NextRow) = ("Test1").......??? <--something
like this?

Test2CommandButton Click()
Sheet("Sheet1".Range("A" & NextRow) = ("Test2").......??? <----again,
something like this?

I know how to store the value with an InputBox but not with a command
button and I would rather use the command button in this particular
case.

Any help would be greatly appreciated, thank you!!!




--
chadtastic
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 4,339
Default Command Button to store a value in Excel/VBA.......

Try

Private Sub CommandButton1_Click()
NextRow = Sheets("Sheet1").Cells(Rows.Count, "A").End(xlUp).Row + 1
Sheets("Sheet1").Range("A" & NextRow) = "Test1"

End Sub"chadtastic" wrote:

Right click on command button and "view code


Hi,

All I need is to know how to use a command button in vba to store a
value in a cell in Excel.

I have a user form with two command buttons on it. one button is
labeled, "Test1", the other labeled, "Test2."

When the user clicks on the button labeled, "Test1", I want the word,
"Test1" to appear in the next available cell in row, "A." When the
user clicks onk, "Test2", I want the word, "Test2" to appear in the
next available cell in row, "A."

I want it set up so that every time the user clicks on either button,
it stores the value in the next available row without replacing the
exiisting value that is in the cell. So say the user clicks on the,
"Test1CommandButton", it stores, "Test1" in, "A1." And the next time
they click the, "Test1(or Test2)CommandButton", it stores, "Test1"(or,
"Test2"), in, "A2", ect..........Thats it.

I'm guessing the code is something like the following.......

Test1CommandButton Click()
Sheet("Sheet1").Range("A" & NextRow) = ("Test1").......??? <--something
like this?

Test2CommandButton Click()
Sheet("Sheet1".Range("A" & NextRow) = ("Test2").......??? <----again,
something like this?

I know how to store the value with an InputBox but not with a command
button and I would rather use the command button in this particular
case.

Any help would be greatly appreciated, thank you!!!




--
chadtastic

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
how to create a command button, then assign macro to it in excel kshaheen Excel Discussion (Misc queries) 3 June 24th 08 01:03 PM
Printing Access reports through Excel command button? Ed Excel Discussion (Misc queries) 0 June 7th 06 03:52 PM
adding a command button to an excel cell? betelguese Excel Discussion (Misc queries) 1 March 22nd 05 03:09 AM
command button in excel will move when print. [email protected] Excel Discussion (Misc queries) 1 December 29th 04 03:53 PM
How do I setup a print command button in excel 2003 BigPunchy New Users to Excel 1 December 24th 04 11:54 PM


All times are GMT +1. The time now is 10:51 AM.

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

About Us

"It's about Microsoft Excel"