When I run this code block, it produces
runtime error 1004 : application-defined or object defined error
But VBA is working and the debug line should be py.Range(py.Cells(row, coloum + level), py.Cells(row, coloum - level)).Value = "*"
. How to fix it?
Dim wantnum As Integer
Dim py As Worksheet
Dim inputs As Integer
Dim row As Integer
Dim coloum As Integer
Dim count As Integer
Dim level As Integer
Set py = Sheets("sheet4")
inputs = InputBox(" Enter the pyrimad level you want")
row = 1
coloum = inputs
level = 0
For count = 0 To inputs
py.Range(py.Cells(row, coloum + level), py.Cells(row, coloum - level)).Value = "*"
row = row + 1
level = level + 1
Debug.Print Error$(count)
Next count
end sub