I have code to trigger a macro once a specific cell is changed, the macro triggers this code:
If there is not at least 2 rows of data in the "Data_Log" range then I get Error 1004. Is there any form of "if" statement I can add to the line of code above to trigger a MsgBox instead of that error?Sub FilterLog() Range("Data_Log").AdvancedFilter Action:=xlFilterCopy, copytorange:=Range("DataOut"), criteriarange:=Range("Criteria") End Sub
Last edited by nohero; 06-30-2011 at 02:54 PM.
nohero,
Something like this?
Sub FilterLog() If Range("Data_Log").Rows.Count < 2 Then MsgBox "The range ""Data_Log"" contains less than 2 rows" Else Range("Data_Log").AdvancedFilter Action:=xlFilterCopy, copytorange:=Range("DataOut"), criteriarange:=Range("Criteria") End If End Sub
Hope that helps,
~tigeravatar
Works like a charm, first try. I really wish the forum allowed me to give you back to back +rep since it was 2 separate issues you just helped me with.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks