Excel vba: Getting a sum then using that value to figure percentage

OALes

New Member
Joined
May 29, 2024
Messages
7
Office Version
  1. 2016
Platform
  1. Windows
  2. MacOS
I need to sum a column of numbers that always begins at H10 but the last row will vary based on an unknown number of data entries. After I get the total I need to divide by 51 to get the percentage I need.

I have some code that is working on my MacBook, but when I take it to Windows it isn’t working. I’m sorry, I don’t have that code handy. My MacBook runs Excel 365 and the PC runs Excel 2016.
 
ROWS(A:A) just returns the total number of rows in Column A. Older versions of Excel had 65536 and newer versions have 1048576.

You could replace that with a number larger than you would ever need if you want.
=SUM(H10:H65000)/51

I don't have a Mac but in PC VBA something like this?

VBA Code:
Range("J1") = Application.WorksheetFunction.Sum(Range("H10:H" & Rows.Count)) / 51
This is exactly what I need! Worked like a charm. Thank you so much.
 
Upvote 0

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
This is exactly what I need! Worked like a charm. Thank you so much.

The marked solution has been changed accordingly. In your future questions, please mark the post as the solution that actually answered your question, instead of your feedback message as it will help future readers. No further action is required for this thread.
 
Upvote 0

Forum statistics

Threads
1,223,894
Messages
6,175,254
Members
452,623
Latest member
Techenthusiast

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