xunda_gunda
New Member
- Joined
- Aug 17, 2012
- Messages
- 22
Hello,
I want your help.
I want to use macro, that will search a blank cells in predetermined range and if cell is empty it should paste formula.
I want to run this macro automatically in every 1 second.
I searched procedures like this and tried to adjust to my excel, but something goes wrong.
Red part of code is not working:
Run-time error ‘1004’:
Application-defined or object defined error
What am I missing?
Thank you in advance.
I want your help.
I want to use macro, that will search a blank cells in predetermined range and if cell is empty it should paste formula.
I want to run this macro automatically in every 1 second.
I searched procedures like this and tried to adjust to my excel, but something goes wrong.
Code:
Sub Check_Empty_Cells_in_Every_3_Seconds()
Application.OnTime Now + TimeValue("00:00:01"), "Fill_Empty_Cells_with_Formulas"
End Sub
Sub Fill_Empty_Cells_with_Formulas()
Dim rng As Range
Dim i As Long
'Set the range in column A you want to loop through
Set rng = Range("D15:D139")
For Each cell In rng
'test if cell is empty
If cell.Value <> "" Then
'write to adjacent cell
[COLOR=#ff0000] cell.Offset(0, 0).Value = "=IF(ISTEXT(INDIRECT(ADDRESS(ROW(),COLUMN()-2,4),TRUE)),"",IF(INDIRECT(ADDRESS(ROW(),COLUMN()-2,4),TRUE)<12,"",IF(INDIRECT(ADDRESS(ROW(),COLUMN()-2,4),TRUE)<=$D$8,"",IF(OFFSET(INDIRECT(ADDRESS(ROW(),COLUMN()-2,4),TRUE),-12,2)<>"",MIN(OFFSET(INDIRECT(ADDRESS(ROW(),COLUMN()-2,4),TRUE),-12,2),INDIRECT(ADDRESS(ROW()-1,COLUMN()+3,4),TRUE)),""))))"[/COLOR]
End If
Next
End Sub
Run-time error ‘1004’:
Application-defined or object defined error
What am I missing?
Thank you in advance.
Last edited: