Inserting new row doesnt updat autosum

ipbr21054

Well-known Member
Joined
Nov 16, 2010
Messages
5,251
Office Version
  1. 2007
Platform
  1. Windows
Morning,

I use the code below to transfer my userform values to my selected row on the worksheet.
Currently the autom in cell K25 is =SUM(K9:K24)

The last row with data in it at present is row 24

When i next use the form an insert to worksheet i see the new row with values added but was expecting the autosum code to update itself of which it doesnt.
Reason being now i have a new the last row with values in it is row 25 but the autosum doesnt update to then cover the new row


Rich (BB code):
Private Sub CommandButton1_Click()
 Dim i As Integer
 Dim ControlsArr As Variant, ctrl As Variant
 Dim x As Long
 Dim z As Integer
 z = CInt(Application.InputBox("INSERT DATA TO WHICH ROW ?", "ROW NUMBER MESSAGE BOX", Type:=1))
 For i = 1 To 11
 With Me.Controls("TextBox" & i)
 If .Text = "" Then
 MsgBox "ALL FIELDS MUST BE COMPLETED", 48, "GRASS NEW CUSTOMER FORM"
 .SetFocus
 Exit Sub
 End If
 End With
 Next i
 
 ControlsArr = Array(Me.TextBox1, Me.TextBox2, Me.TextBox3, Me.TextBox4, Me.TextBox5, Me.TextBox6, Me.TextBox7, Me.TextBox8, Me.TextBox9, Me.TextBox10, Me.TextBox11)
  With ThisWorkbook.Worksheets("GRASS")
 .Rows(z).EntireRow.Insert Shift:=xlDown
 For i = 0 To UBound(ControlsArr)
 Select Case i
 Case 3
 .Cells(z, i + 1) = Val(ControlsArr(i))
 ControlsArr(i).Text = ""
 Case Else
 .Cells(z, i + 1) = ControlsArr(i)
 ControlsArr(i).Text = ""
 End Select
 Next i
 End With
 
 Application.ScreenUpdating = False
 ActiveWorkbook.Save
 Application.ScreenUpdating = True
 With ThisWorkbook.Worksheets("GRASS")
 .Range("A5").Select
 .Range("A4").Select
 MsgBox "DATABASE HAS NOW BEEN UPDATED", vbInformation, "SUCCESSFUL MESSAGE"
 End With
 Unload GRASSNEWCUSTOMER
End Sub
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
One way is to change the formula in K25 to : =SUM(K9:OFFSET(K25,-1,0))
 
Upvote 0
Solution

Forum statistics

Threads
1,215,783
Messages
6,126,876
Members
449,346
Latest member
Janspook03

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top