Sum Values using VBA | Coding in Excel

preview_player
Показать описание
In this video, you will learn to write a code to sum values from a range of cells. To write a code for this, you need to use the Worksheet Function property. So make sure to watch this video till the end.

📰 Transcript
Hey, this is Puneet back again. And welcome to our VBA series where we learn to write codes in Excel. And before we jump in, make sure to subscribe to the channel so that you won't miss any of these videos in the coming weeks. And now let's get started. So here we will look at how we can write a VBA code to SUM values from a range of cells. Now for this, I'm going to go to the Developer tab and then open the Visual Basic editor and then go to the insert option and then module. So here's my new module where I'm going to write the code. Let me name the macro first. Now the first thing that I need to use is the application object and then the worksheet function. So when you use this WorksheetFunction property, it gives you access to all the functions that you have in Excel. So as soon as I enter dot it shows me a list of all the functions that I have in Excel. And from here I'm going to use the sum function. And now I'm going to specify the range for which I want to calculate the sum. That's the range A1 to A16. Now I'm going to use the cell B1 to get the result of this function. All right, so if I run this code, it returns a sum of all the values that we have in range A1 to A16 in cell B1. So you need to use the worksheet function and then you need to use the sum function and you need to specify the range from where you want to calculate the sum. And if you want to sum values from an entire column, in that case, you simply need to specify the column in this way. So this will actually sum all the values from column A. And if you want to go with an entire row, in that case this will be like this, the row one, or if you want to go with row two or row three, so on and so forth. All right, so that's it for this video. I hope you found this quick VBA tip useful. And if you want to learn more, make sure to subscribe to this channel because I'll be coming out of a lot of cool VBA tips and tricks in the coming weeks.

#ExcelVBA #LearnVBA #VBATutorial #VBA

Рекомендации по теме
Комментарии
Автор

How would i use vba to make a sum for a shift calendar. That says if a cell for that day has (specific shift and color) then the those totals would be added. So for example if monday has 3, A 6:30-3:00 AC. I want those to total as 3 under monday. What im trying to do is have each working shift valued as 1 so when added you get that total and any off shifts valued as 0 so it doesn’t effect the total

Msserena
Автор

I need to use vba, once i click on a shape the sum will be A2: A16, each time i click the sum goea down one Row A3: A 16.. can u help ?

eliachurchur
Автор

how to calculate sum of a cell of multiple worksheets?

WilreaJunisseSumang
Автор

how to calculate autosum on bottom by vba

Vikas_Bhalekar
visit shbcf.ru