0
votes

Please help me to solve this. Once I run this VBA macro it shows an error mentioning the Application-defined or object define error.

Code:

Sub income_status()
Dim i As Integer

For i = 1 To 10
  Cells(i, 0) = ActiveCell.Value

  If Cells(i, 0) <= 10000 Then
    Cells(i, 1) = "Low Income"
  ElseIf Cells(i, 0) > 10000 And Cells(i, 0) <= 50000 Then
    Cells(i, 1) = "Medium Income"
  Else
    Cells(i, 1) = "High Income"
  End If    
Next i

End Sub
1
there is no column 0. Column A is 1 not 0. - Scott Craner
As Scott mentioned, there is no column 0. However ... are you really trying to access column 0, or are you trying to perform some sort of Offset from the current cell? At the moment your code, even if you change the , 0 and , 1 to , 1 and , 2 respectively, is just taking the one (active) cell and placing that same value into 10 rows with the same corresponding description placed into the column next to it. Are you instead trying to process the 10 different values in the 10 rows starting from the current cell? - YowE3K

1 Answers

0
votes

There is no Cells (1,0). The index for row or column always starts with 1