View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
Norman Jones Norman Jones is offline
external usenet poster
 
Posts: 5,302
Default Command button code

Hi Gary,

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

Try:

'=============
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

Me.Range("A10").EntireRow.Insert
End Sub
'<<=============

Change the location A10 to suit.

---
Regards,
Norman