PDA

View Full Version : If filename is in sheet, return true/false?



Ago
04-26-2010, 07:45 PM
Im making a summary workbook which gets data from other workbooks in the same directory.
The macro is supposed to run each time i run the file.

But now the problem, i dont want multiple rows of the same data.
So im trying to create a if-statement like this



If stFile <> Application.Workbooks(1).Name Or WorksheetFunction.CountIf(Range("A"), Left(stFile, InStr(stFile, ".") - 1)) Then



stFile is the name of the current file ist about to get data from.
The first part of the if makes sure its not trying to pull data from itself.
After that im trying to figure out if the filename is already listed somewhere in column A.
I have tried vlookup, match and now countif to work but i cant get any of them working the way i want.

I just need a way to figure out if the filename is in column A without it returning a error code if its false, which both vlookup and match does.
Please help.


And why do i keep geting this errormessage from excel every 5 minutes, Its really ****ing me off!
How do i disable it, i know it contains macros.

Bob Phillips
04-27-2010, 12:31 AM
Does this help



If stFile <> Application.Workbooks(1).Name Or WorksheetFunction.CountIf(Columns("A"), Left(stFile, InStr(stFile, ".") - 1)) Then

Ago
04-27-2010, 06:44 AM
That worked, it returned a number. And that meant it was just a smal tweak in the if statement.
Thanks!!

Anyone have an idea about the other problem?

mbarron
04-28-2010, 09:34 AM
The warning is not about the macros, it is about the links. I think the only way you may be able to turn it off is to disable auto saving.