Hi Nola,
I believe most of what you want to do is based on creating a vlookup to determine the month. In that case, you would probably want a vlookup with an approximate result. or a vlookup :
Formula:
=vlookup(c2,Sheet2!A:B,2,True)
. If that is possible, then assuming the mastersheet is always complete. Delete the monthly sheets each time the macro runs and populate it with the all of the data, and set up the macro to sort the data by cars, or customers or both. I find name ranges to be extremely helpful. For now, I have attached an example of how to get months from calendar dates with fiscal month. Without a workbook to go by I would be shooting in the dark to write a macro.
Here is the code:
Sub MoveData()
Dim Ws As Worksheet
Dim xlCell As Excel.Range
Dim xlCell1 As Excel.Range
Dim strMonth As String
For Each Ws In ActiveWorkbook.Worksheets
If Ws.Name = "Data" Then GoTo SkipDelete
If Ws.Name = "FiscalCalendar" Then GoTo SkipDelete
With Ws
If .AutoFilterMode = True Then .AutoFilterMode = False
.Cells.Delete
End With
SkipDelete:
Next Ws
With Sheets("Data")
If .AutoFilterMode = True Then .AutoFilterMode = False
End With
Call RangeName(Worksheets("Data"))
Call RangeName(Worksheets("FiscalCalendar"))
For Each xlCell In Range("MonthTbl")
strMonth = xlCell
With Sheets("Data")
If .AutoFilterMode = True Then .AutoFilterMode = False
End With
Sheets("Data").Select
Set xlCell1 = Range("Month").Find(What:=strMonth, LookIn:=xlValues, Lookat:=xlWhole)
If Not xlCell1 Is Nothing Then
Cells(1, 1).AutoFilter Field:=Range("Month").Column, Criteria1:=strMonth, Operator:=xlFilterValues
Range("A1").CurrentRegion.Copy
Sheets(strMonth).Range("A1").PasteSpecial xlPasteAll
End If
Next xlCell
End Sub
Private Sub RangeName(xlws As Worksheet)
xlws.Select
Application.DisplayAlerts = False
Range("A1").CurrentRegion.Select
Range("A1").CurrentRegion.CreateNames Top:=True, Left:=False, Bottom:=False, Right:=False
Application.DisplayAlerts = True
End Sub
Bookmarks