so I'm working on an excel macro that simply prints values from external data to another sheet. The column and row headers can change position based on the external data so I used find then intersect to get the values I needed. It works well enough until I needed to print the SUM of multiple values. I'm also using option buttons to change what rows the values print to based on which is checked. An example of the working code:
Sub XXXXTest()
Application.ScreenUpdating = False
Dim ToutControl As Integer
'XXXX
'Selects XXXX total by finding string headers then intersecting
Dim xPath As String
Dim xTot As String
Dim xCol As Range
Dim xRow As Range
ActiveWorkbook.Sheets("Rodeo1").Activate
xPath = "Rowheader"
xTot = "ColumnHeader"
Set xRow = Columns(1).Find(xPath)
If xRow Is Nothing Then GoTo NextB
Set xCol = Rows(1).Find(xTot)
If xCol Is Nothing Then msg = msg & vbLf & xTot
If msg = "" Then
Intersect(xRow.EntireRow, xCol.EntireColumn).Activate
Else
End If
'Looks at option button control value and depending on said value, will write Trans value from above in different rows
ToutControl = Sheets("Trans Out").Range("$A$3").Value
If ToutControl = 1 Then
Sheets("Trans Out").Range("$I$4").Value = ActiveCell.Value
ElseIf ToutControl = 2 Then
Sheets("Trans Out").Range("$I$5").Value = ActiveCell.Value
ElseIf ToutControl = 3 Then
Sheets("Trans Out").Range("$I$6").Value = ActiveCell.Value
ElseIf ToutControl = 4 Then
Sheets("Trans Out").Range("$I$7").Value = ActiveCell.Value
ElseIf ToutControl = 5 Then
Sheets("Trans Out").Range("$I$8").Value = ActiveCell.Value
ElseIf ToutControl = 6 Then
Sheets("Trans Out").Range("$I$9").Value = ActiveCell.Value
ElseIf ToutControl = 7 Then
Sheets("Trans Out").Range("$I$10").Value = ActiveCell.Value
ElseIf ToutControl = 8 Then
Sheets("Trans Out").Range("$I$11").Value = ActiveCell.Value
ElseIf ToutControl = 9 Then
Sheets("Trans Out").Range("$I$12").Value = ActiveCell.Value
ElseIf ToutControl = 10 Then
Sheets("Trans Out").Range("$I$13").Value = ActiveCell.Value
ElseIf ToutControl = 11 Then
Sheets("Trans Out").Range("$I$14").Value = ActiveCell.Value
Else: MsgBox "Please Select A Time"
End If
How would I go about doing the same thing but with multiple rows intersecting with the same column and then printing the sum of the returned values into cells like I did above?