nniedzielski
Well-known Member
- Joined
- Jan 8, 2016
- Messages
- 598
- Office Version
- 2019
- Platform
- Windows
I am currently running a Macro that takes items from a List:
And I run this code to scroll through the Master Inventory worksheet and pulls anything that is on this list onto the Fruits Tab, then removes some un-needed columns, and does some formatting.
What I need to add to this functionality is the ability to set a Max number of Fruits:
In this i would only want the macro to grab the first 12 rows of data with Lemons in it, first 5 with Oranges and so on and so forth and move them to the fruits tab.
How can i add this in?
thank you as always for any help, Stay safe
And I run this code to scroll through the Master Inventory worksheet and pulls anything that is on this list onto the Fruits Tab, then removes some un-needed columns, and does some formatting.
VBA Code:
With Worksheets("Lists")
mtArray = .Range("C2", .Range("C" & Rows.Count).End(xlUp))
End With
With Sheets("Master Inventory")
.Range("A1:S1").AutoFilter field:=1, Criteria1:=Application.Transpose(mtArray), Operator:=xlFilterValues
.AutoFilter.Range.Copy Sheets("Fruits").Range("A1")
.AutoFilter.Range.Offset(1).EntireRow.Delete
.Range("A1:S1").AutoFilter
End With
With Sheets("Fruits").Range("D:S")
.EntireColumn.Delete
End With
With Sheets("Fruits").Range("A1:C1")
.Font.Bold = True
End With
With Sheets("Fruits").UsedRange.Borders
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
Sheets("Fruits").UsedRange.EntireColumn.AutoFit
What I need to add to this functionality is the ability to set a Max number of Fruits:
In this i would only want the macro to grab the first 12 rows of data with Lemons in it, first 5 with Oranges and so on and so forth and move them to the fruits tab.
How can i add this in?
thank you as always for any help, Stay safe