코드 다음에 몇 번 작동하면 두 개 이상의 값에 대해 오버플로를 언급하는 오류가 표시됩니다. 각 열의 값에 대해 VBA 코드를 작성하여 각 범주의 세 가지 범주와 개수를 구분하기 만하면됩니다. 이 코드의 오류를 알려주십시오.VBA Excel Do while 및 If 조건
Sub income_status()
Dim income As Integer
Dim locount As Integer
Dim mecount As Integer
Dim hicount As Integer
Do While ActiveCell.Value <> ""
income = ActiveCell.Value
If income <= 10000 Then
ActiveCell.Offset(0, 1).Value = "Low Income"
locount = locount + 1
ElseIf income > 10000 And income <= 50000 Then
ActiveCell.Offset(0, 1).Value = "Medium Income"
mecount = mecount + 1
Else
ActiveCell.Offset(0, 1).Value = "High Income"
hicount = hicount + 1
End If
ActiveCell.Offset(1).Select
Loop
ActiveCell.Offset(1, 2).Value = locount
ActiveCell.Offset(1, 2).Value = mecount
ActiveCell.Offset(1, 2).Value = hicount
End Sub
정확한 오류를 공유 할 수 있습니까? –
변수를 long으로 선언해야합니다. 'Dim income As Long' – OpiesDad
[Excel VBA 소개 파트 5 - 셀 (범위, 셀, 활성 셀, 끝점, 오프셋) 선택] (https : // www.youtube.com/watch?v=c8reU-H1PKQ&index=5&t=3043s&list=PLNIs-AWhQzckr8Dgmgb3akx_gFMnpxTN5) –