View Single Post
  #1   Report Post  
Frantic Excel-er
 
Posts: n/a
Default Macro - message box if find nothing

Hi All,

I currently have a huge macro that I use to import .asc files into excel for
validation, and other things. This macro separates project accounts from non
project accounts and performs a series of tasks on the project accounts. The
project accounts can be differentiated from non project accounts because they
all have an "X" in them...

So, in my code, I first have to import the delimited data, set up column
breaks, and then sort by my account column to get all of the account data at
the bottom of the wkst...(code is already written for this, and I have been
working on it for a month, so I don't want to change it). With that said, I
have my macro find "X" and then put a page break between all the project
accounts, and the non project accounts so I can then do all my tasks with
project accounts...

So, now that I explained some stuff....here is the problem (question)...
If the macro does not find any "x" in column C, then it will pop up an error
saying macro can't run...etc...etc....

What I would like for it to do is pop up a message box that says " No
Project Accounts Found", and then have the macro stop there, because all
other tasks past that point are for the projects.

Here is what part of my code looks like:

(lots of stuff before this...vlookup tables, formatting,etc)

Sheets("Modified").Select
Selection.Sort Key1:=Range("C1"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
Columns("C:C").Find(What:="x").EntireRow.Insert
Selection.End(xlDown).Select
Selection.End(xlDown).Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlToRight)).Select
Selection.Sort Key1:=Range("D:D"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom

Any suggestions on how I can get it to put that message box in??????

Thanks in advance, and sorry for being wordy....

Sara