'välj mellan vilka månader du vill se i fakt. dat. kolumnen Dim x As Long, y As Long, RESP1 As String, RESP2 As String, Shtx As Worksheet, LstRw As Long
Dim LstRw2 As Long, icol As Long
RESP1 = InputBox("Skriv in siffran som representerar den månad du vill se data FRÅN (beställn. datum). Jan = 1, Feb = 2, Mar = 3, etc...")
If StrPtr(RESP1) = 0 Then Exit Sub
RESP2 = InputBox("Skriv in siffran som representerar den månad du vill se data TILL (beställn. datum). Jan = 1, Feb = 2, Mar = 3, etc...")
If StrPtr(RESP2) = 0 Then Exit Sub
x = DateSerial(Year(Date), RESP1, 1)
y = DateSerial(Year(Date), RESP2 + 1, 0)
Set Shtx = ActiveSheet
Worksheets.Add(after:=Worksheets("Beställn.ordn.1")).Name = "Beställn.ordn."
LstRw = Shtx.Range("B" & Rows.Count).End(xlUp).Row
With Shtx.Range("A3:R" & LstRw)
.AutoFilter Field:=1, Criteria1:= _
">=" & x, Operator:=xlAnd, Criteria2:="<=" & y
On Error Resume Next
.Offset(-2).Resize(.Rows.Count + 3).SpecialCells(xlCellTypeVisible).Copy
With Sheets("Beställn.ordn.").Range("B" & Rows.Count).End(xlUp).Offset(0, -2)
.PasteSpecial xlPasteColumnWidths
.PasteSpecial
End With
On Error GoTo 0
.AutoFilter
End With
With Sheets("Beställn.ordn.")
LstRw2 = .Cells(Rows.Count, "B").End(xlUp).Row
For icol = 6 To 9
.Cells(LstRw2 + 3, icol).Formula = "=SUM(" & .Range(.Cells(4, icol), .Cells(LstRw2, icol)).Address & ")"
Next
.Cells(LstRw2 + 3, 13).Formula = "=SUM(" & .Range(.Cells(4, 13), .Cells(LstRw2, 13)).Address & ")"
.Cells(LstRw2 + 3, 14).Formula = "=SUM(" & .Range(.Cells(4, 14), .Cells(LstRw2, 14)).Address & ")"
End With