함수더하기여러인수.xls
0.04MB
Function plus(ParamArray args() As Variant) As Double
Dim total As Double
Dim arg As Variant
Dim cell As Range
total = 0
For Each arg In args
If TypeName(arg) = "Range" Then
' Range 객체인 경우, 범위 내의 모든 셀의 값을 더합니다.
For Each cell In arg
If IsNumeric(cell.Value) Then
total = total + cell.Value
End If
Next cell
ElseIf IsNumeric(arg) Then
' 숫자 값인 경우, total에 더합니다.
total = total + arg
Else
' 숫자도 아니고 범위도 아닌 경우 오류 발생
Err.Raise vbObjectError + 9999, , "Arguments must be numeric or range objects."
End If
Next arg
plus = total
End Function
'컴퓨터 > 엑셀' 카테고리의 다른 글
vba range rows 항목 값 가져오기 (0) | 2024.08.22 |
---|---|
vba 시트이름 (0) | 2024.08.22 |
vba 값이 없는 범위 시트 순환하면서 삭제하기 - 용량 줄이기 (0) | 2024.08.08 |
vba 선택한 셀 주소 배열에 담아서 합계 처리 (0) | 2024.07.24 |
vba 임대료 주소 배열에 저장 배열에 저장된 주소에 셀색 칠하기, access 외부데이터 가져오기 (0) | 2024.04.20 |