Hi all,
I have an issue regarding 'on error' function in the macro below. Basically, this macro is giving me the findings in a drop down list for each line. For example I have in cells A1 and B1 certain values which can be matched in a database with multiple findings and I will have them in C1 in a drop down list. For each line, I have another drop down list.
The problem for this ' On Error GoTo errora' is that if I have two or more errors when running the macro, it will stop. The error means it doesn't find me any values to be shown in the drop down list.
What I need to do, is to ignore all the errors, no matter how many they are and to go to next line till end. Or to have instead of 'on error' a code which will bring me the phrase 'no findings' or something like that.
I hope my problem was clearly stated. If not, please don't hesitate to ask for further explanations. :)
Thank you all for your help!
I have an issue regarding 'on error' function in the macro below. Basically, this macro is giving me the findings in a drop down list for each line. For example I have in cells A1 and B1 certain values which can be matched in a database with multiple findings and I will have them in C1 in a drop down list. For each line, I have another drop down list.
The problem for this ' On Error GoTo errora' is that if I have two or more errors when running the macro, it will stop. The error means it doesn't find me any values to be shown in the drop down list.
What I need to do, is to ignore all the errors, no matter how many they are and to go to next line till end. Or to have instead of 'on error' a code which will bring me the phrase 'no findings' or something like that.
I hope my problem was clearly stated. If not, please don't hesitate to ask for further explanations. :)
Thank you all for your help!
Code:
With Sheets1
.Select
Firstrow = .UsedRange.Cells(1).Row
Lastrow = CStr(Range("A" & CStr(Application.Rows.Count)).End(xlUp).Row)
For Lrow = Lastrow To Firstrow Step -1
With .Cells(Lrow, "B")
If Not IsError(.Value) Then
vd = "_" & Range("B" & Lrow).Value & Range("D" & Lrow).Value
On Error GoTo errora
With Range("E" & Lrow).Validation '<--adds the validation change the values depending on the requirements (default is usually fine)
.delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:="=" & vd & ""
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
End With
errora:
End If
End With
Next Lrow
End With
End Sub