Evening All,
i have managed to pull together a working macro, that goes through several worksheets and filters out required data according to specified date.
This is then copied and pasted to a worksheet called Todays Trades.
We then finish up with a autofit of all columns.
The macro works fine, but.......... as you can see i will need to manually edit the macro each time i want a different date.
Is there a way i can do this only once? Or is there a of pointing to somewhere and saying 'use this date'?
Also open to any improvements on the below macro.
i have managed to pull together a working macro, that goes through several worksheets and filters out required data according to specified date.
This is then copied and pasted to a worksheet called Todays Trades.
We then finish up with a autofit of all columns.
The macro works fine, but.......... as you can see i will need to manually edit the macro each time i want a different date.
Is there a way i can do this only once? Or is there a of pointing to somewhere and saying 'use this date'?
Also open to any improvements on the below macro.
VBA Code:
Sub TodaysTrades()
Dim wsToday As Worksheet: Set wsToday = Sheets("Todays Trades")
Dim wsBTTS As Worksheet: Set wsBTTS = Sheets("BTTS Predict")
Dim wsLTD As Worksheet: Set wsLTD = Sheets("LTD")
Dim wsO25 As Worksheet: Set wsO25 = Sheets("O2.5")
Dim wsCheck As Worksheet: Set wsCheck = Sheets("Check")
Dim wsLazy As Worksheet: Set wsLazy = Sheets("Lazy")
Dim wsHomer As Worksheet: Set wsHomer = Sheets("Homer")
Dim wsMOCS As Worksheet: Set wsMOCS = Sheets("Mocs")
Application.ScreenUpdating = False
With wsBTTS.[a4:f2000].CurrentRegion
.AutoFilter 1, "07/02/2021"
wsBTTS.[b4:f2000].SpecialCells(xlCellTypeVisible).Copy wsToday.Range("a" & Rows.Count).End(3)(2)
.AutoFilter
End With
With wsLTD.[a4:f4000].CurrentRegion
.AutoFilter 1, "07/02/2021"
wsLTD.[b4:d4000].SpecialCells(xlCellTypeVisible).Copy wsToday.Range("g" & Rows.Count).End(3)(2)
.AutoFilter
End With
With wsO25.[a4:f4000].CurrentRegion
.AutoFilter 1, "07/02/2021"
wsO25.[b4:d4000].SpecialCells(xlCellTypeVisible).Copy wsToday.Range("k" & Rows.Count).End(3)(2)
.AutoFilter
End With
With wsCheck.[a4:f4000].CurrentRegion
.AutoFilter 1, "07/02/2021"
wsCheck.[b4:d4000].SpecialCells(xlCellTypeVisible).Copy wsToday.Range("o" & Rows.Count).End(3)(2)
.AutoFilter
End With
With wsLazy.[a4:f4000].CurrentRegion
.AutoFilter 1, "07/02/2021"
wsLazy.[b4:d4000].SpecialCells(xlCellTypeVisible).Copy wsToday.Range("s" & Rows.Count).End(3)(2)
.AutoFilter
End With
With wsHomer.[a4:f4000].CurrentRegion
.AutoFilter 1, "07/02/2021"
wsHomer.[b4:d4000].SpecialCells(xlCellTypeVisible).Copy wsToday.Range("w" & Rows.Count).End(3)(2)
.AutoFilter
End With
With wsMOCS.[a4:f4000].CurrentRegion
.AutoFilter 1, "07/02/2021"
wsMOCS.[b4:d4000].SpecialCells(xlCellTypeVisible).Copy wsToday.Range("aa" & Rows.Count).End(3)(2)
.AutoFilter
End With
Dim x As Integer
For x = 1 To ActiveSheet.UsedRange.Columns.Count
Columns(x).EntireColumn.AutoFit
Next x
Application.CutCopyMode = False
Application.ScreenUpdating = True
End Sub
Last edited by a moderator: