Sum cells

  • Thread starter Thread starter Tdp
  • Start date Start date
Hi,

Put your textbox from the Control toolbox on your worksheet, you then have
choices.

1. While still in design mose right click the textbox and view code and
paste this in

Private Sub TextBox1_GotFocus()
TextBox1.Text = WorksheetFunction.Sum(Range("A1:a10"))
End Sub

Exit design mode and when the textbox is selected the sum is displayed.

or.

2. Exit desing mode and right click the sheet tab, view code and paste this in

Private Sub Worksheet_Change(ByVal Target As Range)
TextBox1.Text = WorksheetFunction.Sum(Range("A1:a10"))
End Sub

The text box now does the sum whenever the worksheet changes.

Mike
 
Link the textbox to a cell in which you have a SUM formula?


Gord Dibben MS Excel MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top