ABC ASD BHP WER THY SUM
1 789 564 654 546 654 3207
2 103 123 213 123 654 1216
3 546 394 879 654 654 2733
제 질문은 어떻게 각 열과 행을 합할 수 있습니까? 틈새 행이 있다면? 각 행을 처리하여 합계를 계산하려고합니다. 데이터에 간격이 없으면 작동하지만 행 사이에 간격이 있으면 각 셀을 완전히 처리하지 못합니다.VBA Excel 합계 열 및 행
Sub test()
Dim intRowTot As Integer
Dim intRowCnt As Integer
Dim intColTot As Integer
Dim intColCnt As Integer
Range("B2").Select
Do Until IsEmpty(ActiveCell)
intRowTot = 0
intColTot = 0
Do Until IsEmpty(ActiveCell)
intRowTot = intRowTot + 1
intColTot = intColTot + ActiveCell.Value
intColCnt = intColCnt + 1
ActiveCell.Offset(1, 0).Select
Loop
ActiveCell.Offset(1, 0).Value = intColTot
ActiveCell.Offset(-intRowTot, 1).Select
Loop
Range("B2").Select
Do Until IsEmpty(ActiveCell)
intRowTot = 0
intColTot = 0
Do Until IsEmpty(ActiveCell)
intRowTot = intRowTot + ActiveCell.Value
intColTot = intColTot + 1
intRowCnt = intRowCnt + 1
ActiveCell.Offset(0, 1).Select
Loop
ActiveCell.Offset(0, 1).Value = intRowTot
ActiveCell.Offset(1, -intColTot).Select
Loop
End Sub`
이에 대한 VBA를 필요로하는 대신 워크 시트의 합계를 표시하는 어떤 이유? – Bathsheba