Macro - How to skip/not look for if no data for a given day

James8761

Board Regular
Joined
Apr 24, 2012
Messages
154
Office Version
  1. 2019
Platform
  1. Windows
Hi,

I tried setting up a simple macro by recording what i was doing. It is around football fixtures. Not all football leagues have games each day. I download the data in to excel then recorded the following macro below. I have a tab for each league at the bottom in the same workbook. This works fine when there are fixtures every day in all leagues.

The problem comes with the bold/italic Belgium First Division B wording. On this day there were no fixtures in this league but the macro is still looking for it/taking ages/and then saves the file as 875mb as opposed to 1mb. Is there any text I can put in to avoid this happening?

Thanks for any help!

Sub Macro3()
'
' Macro3 Macro
'

'
Selection.AutoFilter
Selection.End(xlToRight).Select
ActiveSheet.Range("$A$1:$LR$151").AutoFilter Field:=330, Criteria1:= _
"Australia A-League"
Range("A1").Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
ActiveSheet.Next.Select
Range("A1").Select
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveSheet.Previous.Select
Range("LL168").Select
ActiveSheet.Range("$A$1:$LR$151").AutoFilter Field:=330, Criteria1:= _
"Belgium First Division B"
Range("A1").Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Sheets("Belgium").Select
Range("A1").Select
ActiveSheet.Paste
Application.CutCopyMode = False
Columns("A:E").Select
Columns("A:E").EntireColumn.AutoFit
Sheets("Australia").Select
Columns("A:E").Select
Columns("A:E").EntireColumn.AutoFit
Cells.Select
Sheets(Array("Australia", "Belgium")).Select
Sheets("Australia").Activate
With Selection.Font
.Name = "Browallia New"
.Size = 11
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ThemeColor = xlThemeColorLight1
.TintAndShade = 0
.ThemeFont = xlThemeFontNone
End With
With Selection.Font
.Name = "Browallia New"
.Size = 14
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ThemeColor = xlThemeColorLight1
.TintAndShade = 0
.ThemeFont = xlThemeFontNone
End With
Columns("A:A").Select
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Range("E8").Select
Sheets("excel_tsd_2020-01-10").Select
Range("KS171").Select
End Sub
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes

Forum statistics

Threads
1,215,006
Messages
6,122,666
Members
449,091
Latest member
peppernaut

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top