PDA

View Full Version : VBA SUM Formula help



malleshg24
02-13-2018, 09:16 PM
Hi Team, :help


How to make code dynamic to cover last row if data increase?. Thanks in advance !!

Below is my code it is giving Result 12, Instead of 33,


Sub Test_sum()

Dim lr As Long

lr = Range("B100").End(xlUp)

Range("D2") = Application.WorksheetFunction.Sum(Range("b2:B" & lr))

End Sub



A
B


Name
Count


a
5


b
7


c
10


d
8


e
3




Thanks
Mallesh

pike
02-14-2018, 01:00 AM
Hello,
You need to add the row property
lr = Range("B100").End(xlUp).row

malleshg24
02-14-2018, 09:00 AM
Thanks !