PDA

View Full Version : If not in database then add to database



Djblois
07-03-2006, 06:48 AM
First, I would like to thank everyone for all the help I have gotten. It is really coming along and I am learning alot along the way. However, there is more I want to do to this macro. I think if I show a piece of my code, then explain what I want to do, it will make more sense.

Detail.Columns("E:E").Insert Shift:=xlToRight
Detail.Range("E1").FormulaR1C1 = "Customer"
Detail.Range("E2:E" & Detail.Cells(Detail.Rows.Count, 1).End(xlUp).Row).FormulaR1C1 = _
"=IF(ISNA(VLOOKUP(RC[-1],'[Atalanta Codes.xls]Cust'!C1:C9,2,FALSE)), VLOOKUP(RC[-1],Cust!C[-3]:C[-2],2,FALSE), VLOOKUP(Detail!RC[-1],'[Atalanta Codes.xls]Cust'!C1:C9,2,FALSE))"
Detail.Range("E1:E" & Detail.Cells(Detail.Rows.Count, 1).End(xlUp).Row).Value = _
Detail.Range("E1:E" & Detail.Cells(Detail.Rows.Count, 1).End(xlUp).Row).Value

As you can see in my formula I do a vlookup in Atalanta codes first then I do a vlookup in Cust tab. After that I want it to look at the cust numbers in the cust tab and add it to the atalanta codes if they are not in there (along with there customer names as well.

austenr
07-03-2006, 08:47 AM
Would this not be easier in Access?

Djblois
07-03-2006, 05:02 PM
What do you mean?? it would be easier in access?

acw
07-03-2006, 05:23 PM
Hi

For those of us who haven't been involved in the previous, can you put a link to the other post if it explains what you are doing, or explain your process. I'm guessing that this file is somehow going to update / overtype any existing atlanta codes.xls workbook?

Also, can you not just add another formula similar to the above to get existing detail / new detail for the code?


Tony

Djblois
07-05-2006, 08:34 AM
Here is the link to my full code.

http://www.vbaexpress.com/forum/showthread.php?t=8634

I don't want to rewrite what I have in Atalanta Codes but it is a spreadsheet I use to keep track of the items we sell, our customers, warehouses, etc. and their codes. Right now I update it manually whenever I get a chance but I would like the macro to add any customers or products that are not already in the Atalanta Codes workbook.