View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Gary[_22_] Gary[_22_] is offline
external usenet poster
 
Posts: 10
Default Command button code

On 16 May, 13:11, "Norman Jones"
wrote:
Hi Gary,

Try something like:

'=============
Private Sub CommandButton1_Click()
Dim SH As Worksheet
Dim Rng As Range
Const sStr As String = "ABC" '<<==== CHANGE

Set SH = ThisWorkbook.Sheets("Sheet2") '<<==== CHANGE
Set Rng = SH.Range("A1") '<<==== CHANGE
Rng.Value = sStr
End Sub
'<<=============

---
Regards,
Norman

"Gary" wrote in message

oups.com...



Hi all,


I have created a command button on a worksheet in an Excel 2003
workbook. I just need to assign some code to this button so that when
clicked, it will simply enter text into a cell in another worksheet in
the same workbook.


Sounds very easy to me, but I've not been able to figure it out yet,
or see any examples.


Can someone help me out please?


Thanks a lot.


Gary.- Hide quoted text -


- Show quoted text -


Thanks very much for that. I also need the same button to add a new
row into the worksheet it is located. Can you please help me with
that?

Thanks again.