rachelm920
New Member
- Joined
- Jan 26, 2012
- Messages
- 10
I am attempting to filter an excel spreadsheet and use IF/Then statements.
I have searched this site (and google) high and low and cannot find a solution.
Basically what I need to do is filter all items with a quantity of <-24000 or =-1 Then if the quantity does equal -1 I need it to filter a different column searching for a specific item with that quantity.
I've tried copying all items that have the quantity <-24000 into a new spreadsheet, but when I try to go back to the original and then filter out the specific item code, I receive errors.
I've tried running a for then statement and inputting the filter within it, and that doesn't work either. Right now what I have is the copy/paste idea. At this point I really don't care what method I use, I'd just like the end result. Here's what I currently have:
I am pretty sure the problem is that it cannot locate the file I defined as Iss above. I can't set it to a direct file, because it changes daily (i.e. Issues_01192015.xlsx is today's file name and tomorrow will be 01202015 etc.)
Any assistance with this is greatly appreciated.
I have searched this site (and google) high and low and cannot find a solution.
Basically what I need to do is filter all items with a quantity of <-24000 or =-1 Then if the quantity does equal -1 I need it to filter a different column searching for a specific item with that quantity.
I've tried copying all items that have the quantity <-24000 into a new spreadsheet, but when I try to go back to the original and then filter out the specific item code, I receive errors.
I've tried running a for then statement and inputting the filter within it, and that doesn't work either. Right now what I have is the copy/paste idea. At this point I really don't care what method I use, I'd just like the end result. Here's what I currently have:
Code:
Dim Iss As Workbook
Dim Super As Workbook
Dim IssSheet As Worksheet
Dim SupSheet As Worksheet
'Supermarket Sheet Issues (These are for the <-24000 this portion works fine, and successfully copys/pastes the data into a new spreadsheet named "Supermarket today's date". Done is a file path I have at the beginning of the code this is a HUGE macro LOL)
ActiveWorkbook.ActiveSheet.Range("A1:F1").AutoFilter
ActiveWorkbook.ActiveSheet.Range("A1:F1").AutoFilter Field:=4, Criteria1:="<-24000"
Set Iss = ActiveWorkbook
Set IssSheet = Iss.Sheets("Sheet1")
Set Super = Workbooks.Add
With Super
Set SupSheet = Super.Sheets("Sheet1")
.SaveAs Done & "Supermarket" & " " & Format(Date, "mmddyyyy") & ".xlsx", FileFormat _
:=xlNormal, Password:="", WriteResPassword:="", ReadOnlyRecommended:= _
False, CreateBackup:=False
IssSheet.Range("A1:F999").Copy
SupSheet.Range("A1").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, _
Transpose:=False
End With
ActiveWorkbook.Close
'This is where the errors start
Iss.Close
Workbooks.Open Iss ' This line is highlighted in yellow and says "Run-time error 424 object required" I am pretty sure it cannot find the "Iss" file I setup above.
Set Iss = ActiveWorkbook
With Iss
Set IssSheet = Iss.Sheets("Sheet1")
I am pretty sure the problem is that it cannot locate the file I defined as Iss above. I can't set it to a direct file, because it changes daily (i.e. Issues_01192015.xlsx is today's file name and tomorrow will be 01202015 etc.)
Any assistance with this is greatly appreciated.