생활/컴퓨터

엑셀 셀 갯수 입력 합계

풍경소리^^ 2016. 6. 5. 11:15

Sub 셀갯수선택합계()

Dim total As Double
total = 0
Dim strs As String
Dim stre As String
Dim i As Integer
i = Application.InputBox("합계할 셀 갯수를 입력하세요", "셀 갯수 입력", , , , , , 1) - 1
strs = ActiveCell.Address
stre = ActiveCell.Offset(i, 0).Address
total = WorksheetFunction.Sum(Range(strs, stre))
'MsgBox "시작주소=" & strs & Chr(10) & "끝주소=" & stre & Chr(10)
MsgBox "셀 갯수=" & i + 1 & Chr(10) & "범위합계=" & Format(total, "###,0")
ActiveCell.Offset(i + 1, 0).Select

End Sub