Match exact two cells in same row and delete. -Please Help

Hatcheda

Active Member
Joined
Dec 8, 2005
Messages
354
Hey, I am kinda new at this. I am learning the program quickly but am stuck on this issue. Heres the situation. I am using a macro in Excel to import information from a varity of reports. I then import the Excel sheet into an Access database that stores and reexports the data in a varity of forms. If the info has an error when imported from excel I run into major problems. Duplicate info can not exsist. Information is only imported once a month and is always dated the first of the month. I would like a macro that will search for exact information in two cells.

example
reference---other data---other data---date
12344-------varies--------varies--------09/01/2005
12344-------varies--------varies--------09/01/2005
12345-------varies--------varies--------12/01/2005
12345-------varies--------varies--------12/01/2005

12344-------varies--------varies--------10/01/2005
12344-------varies--------varies--------10/01/2005
12344-------varies--------varies--------11/01/2005
12344-------varies--------varies--------12/01/2005
12345-------varies--------varies--------12/01/2005

I will use what ever I am given in for Access data base with two text boxes. The first I will type in the Reference # and in the second, the date.

12345 12/01/2005 in the boxes will delete all that have those values in them. The macro should be based off rows, I think. and only delete rows that match both text boxes. -no non matching rows above or below. The reference # and date may appear many times. 20+ and are not always in order. Also there may be spaces in some rows. I need an exact match to what I enter. only deleting what I enter. -very, very important. I can point the macro to the text boxes and assign a button. also this will need to work on 6 tables with one click. The button will be in a form and will need to point to 6 tables. Also the row will need to shift up. not just clear the cells because the other data in the row varies and will still cause errors once I reimport. Please help if you can. -Thanks David
Code:
 

Some videos you may like

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.

acw

MrExcel MVP
Joined
Feb 13, 2004
Messages
4,814
Hi

So you want to delete the rows of data where the reference and date match the selection criteria? And where are the 6 tables you mention? Are they on the same sheet, or in different sheets in the workbook? Where are the cells containing the selection critieria for deletion?


Tony
 

Hatcheda

Active Member
Joined
Dec 8, 2005
Messages
354
the same info will be on 6 sheets. I will modify the code to find them. They are in an Access Database on different tables. Yes I do want to delete the rows of data that contain only both exact entries. the reference number will exsist for every month several time, so I need it to focus on only the months I specify. 11/1/2005, or what ever that may be. Mth, Date, Year. But it could work as a text search because I will write it exactly. the cells are in column 1 and 4. ref and date. the two in the middle change and are not searchable. I just need to locate ref and date exactly on every post and delete them. they may/will be mixed in with others. mostly I just need to know how to search two cells on a row at once, if column one matches text box one and column four matches text box two then delete. please help if you can
 

acw

MrExcel MVP
Joined
Feb 13, 2004
Messages
4,814
A couple of other questions.

1) Confirm that this is being run in Excel, not access
2) Where are the textboxes? Are they on a particular sheet on the workbook, or in a userform?
3) What are the names of the textboxes and the relevant sheets (if in excel).


Tony
 

Watch MrExcel Video

Forum statistics

Threads
1,118,058
Messages
5,569,957
Members
412,300
Latest member
Chaneycr
Top