keith05281967
Board Regular
- Joined
- May 6, 2011
- Messages
- 68
Greetings VBA Guru's,
I have 2 questions:
1. I recorded a macro to select column A, find and delete any duplicates found. Here is the code:
Columns("A:A").Select
ActiveSheet.Range("$A$1:$A$37").RemoveDuplicates Columns:=1, Header:=xlYes
I need the code to tell the user if no duplicates were found or if found, give the option to proceed with deleting or not. I'm sure this is an If stmt, but I don't know how to word it.
2. Somewhat similar to the 1st, I have some code that locates a column header. The code is listed below:
On Error GoTo Err1:
Cells.Find(What:="sale_date", after:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False).Activate
The problem i'm having is that if the column isn't found I get an error. I tried to solve that with the "On Error GoTo Err1:" sometimes it works and sometimes it doesn't. I'd rather have some kind of if stmt if not found then.....something that informs the user column "sale_date" isn't found, moving on.
thanks so much. I'm using excel 07.
Also can you please use code examples with explanations?
thanks in advance for your help,
Keith
I have 2 questions:
1. I recorded a macro to select column A, find and delete any duplicates found. Here is the code:
Columns("A:A").Select
ActiveSheet.Range("$A$1:$A$37").RemoveDuplicates Columns:=1, Header:=xlYes
I need the code to tell the user if no duplicates were found or if found, give the option to proceed with deleting or not. I'm sure this is an If stmt, but I don't know how to word it.
2. Somewhat similar to the 1st, I have some code that locates a column header. The code is listed below:
On Error GoTo Err1:
Cells.Find(What:="sale_date", after:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False).Activate
The problem i'm having is that if the column isn't found I get an error. I tried to solve that with the "On Error GoTo Err1:" sometimes it works and sometimes it doesn't. I'd rather have some kind of if stmt if not found then.....something that informs the user column "sale_date" isn't found, moving on.
thanks so much. I'm using excel 07.
Also can you please use code examples with explanations?
thanks in advance for your help,
Keith