[Solved] Excel Formula Question

Michelle11

New member
I have the below spreadsheet for 25 times for a small league that I am running. I need to take where it says number and put it to the total spots for 25 times like this. How would I do that? Do you have any ideas? Also it goes down 30 lines so there is multiple pages of this as well. There is on the first page 4 like this and then 3 on each additional page like this but each has to have the running total.

WordsWordsnumberWordsWordsnumberTotalWordsWordsnumberTotal
 
Hello Michelle11,
Thanks for sharing your problem with us. I understand that you want to take values from number columns and put them into the Total columns for each table in every worksheet.

As you require 25 tables with 4 tables on the first page and 3 tables on the remaining page, we will require 8 worksheets. I prepared the following tables:​

sIHhxUnhlFfcUBCdYfr5ewlw4tUp07DH7Y-CpgzVG-dp9rrZaJUEXcK7XYpVkEJov80IzpR3h-6o4R3nYROhy5OuQ64--u8InZiDjdxPdBn44FuDYph_yAI5DBzqynKv3iqwq145HEHb8VkOkH3dAwY

We will use a simple VBA code to calculate the total value for each number we find and place it in the subsequent Total column.

First, go to the Developer tab and click the Visual Basic option. If you don’t have the Developer tab, then use the keyboard shortcut Alt + F11 as an alternative.​

7GZhWfSd7D3GVaR_jPAlTh8NM_nlF1mbW4yYE1szxhHiMdS16r-jEXLGXRJYvo1M2ofmysJrq62aD1944YjBGb0ug9E3ySZqrfQFJUU-S0KGYO9GPvIJfUEnTJvnBMZ88JbJFsOCdq_d5PQS0756afo

Then click the Insert tab and select the Module option.

f6vAiiML_suydZr1R4AaOn08s3Hmosl8M95iL6XC4QtJ64oqVI5_S8DRBpqAVWd4sqI3lfHthgUIBgx8dJdLET55A0eVI-_f5dWXyH_7nvymtcqVpr-m4RPl4C-w3kuNw4FvEdk2vGh3tb_yNMjQPVw

Enter the following VBA code in the module. Save and Run this code.

VVDv_e7ULDJOTnkxglbhgIk7r4AXHy_7Lw7yLoMjzOMP_kINBT_pb7RKWTwEjqXbKPn_04v_t1hVwWmboFQBkwd68z3ewSONeql9Y2aSZ7DgnOpEDTv41rj1U74Vv8leKaaE9_FxHwI7D96qeXXKmH8

Code:
Sub SumNumbersInTotalSpot()
    
    Dim last_row As Integer
    Dim last_col As Integer
    Dim total_val As Integer
    Dim i As Integer
    Dim j As Integer
    
    For Each wrksht In ThisWorkbook.Sheets
        last_row = wrksht.Cells(Rows.Count, 1).End(xlUp).Row
        last_col = wrksht.Cells(1, Columns.Count).End(xlToLeft).Column
        For i = 1 To last_row
            total_val = 0
            For j = 1 To last_col
                If IsNumeric(wrksht.Cells(i, j).Value) Then
                    total_val = total_val + wrksht.Cells(i, j).Value
                End If
                If wrksht.Cells(1, j).Value = "Total" And total_val <> 0 Then
                    wrksht.Cells(i, j).Value = total_val
                End If
            Next j
        Next i
    Next wrksht
End Sub

After executing this code, all numbers will be summed and placed in the subsequent cells of the Total column.​

dP3rYiWJZvSqh97h74NdlxZGF5r3w64fjnzLwMoJX1qJtpbUp9gg5Yg-eO09juwFBqQqy0XgRZVuaRQeEH3zigFM0NcrqAYQl7NKxyZTxjxxKJ3WFCVQ2YRsFGMffIju_eh0-Jvlem8mcHGzm2QQSvs

I hope I was able to provide a sufficient answer to your problem. If you have any other queries for this problem, please share a sample dataset with manual calculations of your problem.​

Let us know your feedback. The workbook used for this problem is attached below.

Regards,
Seemanto Saha
ExcelDemy
 

Attachments

Online statistics

Members online
0
Guests online
168
Total visitors
168

Forum statistics

Threads
460
Messages
2,044
Members
2,321
Latest member
tt88faith
Back
Top