Ottsel
Board Regular
- Joined
- Jun 4, 2022
- Messages
- 174
- Office Version
- 365
- Platform
- Windows
Struggling to create a loop within a loop. Overall, VBA isn't my strongest skill, but trying to improve when and where I can.
Currently, I have the code below that will grab my data and important it onto another sheet to be reviewed.
Sheets("OSB INVOICE") contains my data or orders
Sheets("OSB CALC") contains my sorted table
In column AA I have a formula:
If it says "Import" then I know it meets the criteria to be imported into the "OSB Calc" sheet.
Now, where everything imports to ("OSB Calc") the item code is listed in Range("A5") and the same item code can be found within Column A on ("OSB Invoice").
the idea is to be able to change the item code, hit 'import' and create multiple lists to be reviewed with ease.
Right now it just ignores the item overall and will import anything and everything within the OSB Invoice sheet no matter what the code is, but I would like it to match the code, then if it matches continue onto the next loop.
Any and all help would be greatly appreciated!
Currently, I have the code below that will grab my data and important it onto another sheet to be reviewed.
VBA Code:
Dim r As Long 'row
Dim row As Long 'row count
row = Sheets("OSB Invoice").Range("A:A").Cells.SpecialCells(xlCellTypeConstants).Count
'...Prevent from Forumlas filling all the way down
'Application.ScreenUpdating = False
Application.AutoCorrect.AutoFillFormulasInLists = False
Application.DisplayAlerts = False
'...Clear Slate
Sheets("OSB CALC").Range("A8:E49").ClearContents
Sheets("OSB INVOICE").Activate
For r = 2 To row
If Sheets("OSB INVOICE").Range("AA" & r).Value = "Import" Then
Sheets("OSB INVOICE").Range(Range("AA" & r).Offset(0, 1), Sheets("OSB INVOICE").Range("AA" & r).Offset(0, 5)).Copy
Sheets("OSB CALC").Cells(Rows.Count, 1).End(xlUp).Offset(1).PasteSpecial (xlPasteValues)
Application.CutCopyMode = False
End If
Next r
Sheets("OSB CALC").Activate
Range("F5").Select
Sheets("OSB CALC") contains my sorted table
In column AA I have a formula:
Excel Formula:
=IF(OR(D2<'OSB CALC'!$B$2,D2>'OSB CALC'!$E$2),"","Import")
Now, where everything imports to ("OSB Calc") the item code is listed in Range("A5") and the same item code can be found within Column A on ("OSB Invoice").
the idea is to be able to change the item code, hit 'import' and create multiple lists to be reviewed with ease.
Right now it just ignores the item overall and will import anything and everything within the OSB Invoice sheet no matter what the code is, but I would like it to match the code, then if it matches continue onto the next loop.
Any and all help would be greatly appreciated!