A little help need on adding values in column

Sharid

Well-known Member
Joined
Apr 22, 2007
Messages
1,066
Office Version
  1. 2016
Platform
  1. Windows
Why is this not working

I want to add all the values in column B from row 4 down to last cell with data and the past the TOTAL in Cell B2

Code:
Private Sub CommandButton1_Click()
[FONT=arial]Dim myRange[/FONT][FONT=arial]    
 myRange = ActiveSheet.Range("B4", Range("B4").End(xlDown))
  Range("B2") = WorksheetFunction.Sum(myRange)

End Sub[/FONT]
 
Last edited:

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
Forgot to mention that bit. Lol

it just returns £00.00

So if column B Row 4 and below had

Tshirt = £10.50
Shoes = £30.00
Jacket = 40.00

The answer should be £80.50 in Column B2 and not £00.00
 
Upvote 0
what do you get with a formula?

=sum(B4:B6)
 
Upvote 0
I get £80.50
 
Last edited:
Upvote 0
Forgot to mention that bit. Lol

it just returns £00.00

So if column B Row 4 and below had

Tshirt = £10.50
Shoes = £30.00
Jacket = 40.00

The answer should be £80.50 in Column B2 and not £00.00

Does col B contain £10.50 ,or tshirt = £10.50?
 
Upvote 0
Instead of giving the total value it give me £00.00
 
Upvote 0
It only contains the value,

Column A has the item name e.g. Tshirt Column B has the Amount
 
Upvote 0
Try:

LR = Cells(4, 2).End(xlDown).Row
ActiveCell.FormulaR1C1 = "=SUM(R[2]C:R" & LR & "C)"
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,182
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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