Hello everybody,
I have tried to write a macro checking if cells are empty or not between the named cells "First_sample" and "Last_sample". I start checking the cell below "First_sample" and I want the macro to run until reaching the cell named "Last_sample". The loop works fine first time but second time I get the error message Run-time error '1004': Application defined or object defined error. The code is as below. I am greatful for any help or suggestion.
Kind regards
Ingemar
Sub Macro1()
Worksheets("Analysis sheet").Range("First_sample").Offset(1, 0).Select
Do
On Error GoTo Section2
If ActiveCell.Name.Name = "Last_sample" Then
Exit Sub
End If
Section2:
If IsEmpty(ActiveCell) Then
Selection.Offset(1).Select
Else
'Macro process to be done
End If
Loop
End Sub
I have tried to write a macro checking if cells are empty or not between the named cells "First_sample" and "Last_sample". I start checking the cell below "First_sample" and I want the macro to run until reaching the cell named "Last_sample". The loop works fine first time but second time I get the error message Run-time error '1004': Application defined or object defined error. The code is as below. I am greatful for any help or suggestion.
Kind regards
Ingemar
Sub Macro1()
Worksheets("Analysis sheet").Range("First_sample").Offset(1, 0).Select
Do
On Error GoTo Section2
If ActiveCell.Name.Name = "Last_sample" Then
Exit Sub
End If
Section2:
If IsEmpty(ActiveCell) Then
Selection.Offset(1).Select
Else
'Macro process to be done
End If
Loop
End Sub