OilEconomist
Active Member
- Joined
- Dec 26, 2016
- Messages
- 439
- Office Version
- 2019
- Platform
- Windows
Thanks in advance for any suggestions for which I will provide feedback.
Why am I getting the error: "Run-time error '438': Object doesn't support this property or method" on the following line:
The following is the entire code where I am trying to obtain the column letter of the first non-zero or first non-blank value (cannot be zero).
Why am I getting the error: "Run-time error '438': Object doesn't support this property or method" on the following line:
Code:
Cells(4, i).Formula "= MATCH(TRUE,INDEX(E" & i & ":" & LastColumnLtr & i & "<>0,),0)"
The following is the entire code where I am trying to obtain the column letter of the first non-zero or first non-blank value (cannot be zero).
Code:
Sub Non()
'Dimensioning
Dim i As Long
Dim LastRow As Long
Dim LastColumn As Long
Dim LastColumnLtr As String
Worksheets("Sheet1").Activate
'Find the last row
LastRow = Cells.Find(What:="*", After:=Range("A1"), _
LookAt:=xlPart, LookIn:=xlFormulas, SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious, MatchCase:=False).Row
'Find the last column & turn into letter
'Find the last column
LastColumn = Cells.Find(What:="*", After:=Range("A1"), LookAt:=xlPart, _
LookIn:=xlFormulas, SearchOrder:=xlByColumns, SearchDirection:=xlPrevious, _
MatchCase:=False).Column
'Turn into letter
LastColumnLtr = Split(Cells(1, LastColumn).Address, "$")(1)
'Find the first non-zero or non-blank cells
For i = 4 To LastRow
Cells(4, i).Formula "= MATCH(TRUE,INDEX(E" & i & ":" & LastColumnLtr & i & "<>0,),0)"
Next i
End Sub