Dear all,
I'm the match secretary of our local football club. Each weekend I need to provide an overview of all matches to be played that weekend, showing which field, what time, etc.
I've build an excel sheet to generate this overview from an export from the special software we use to plan the matches.
My knowledge of VBA is quite limited but by browsing on forums, recording macros and looking at the code and some common sense I managed to build a script that does exactly what I want.
I'm using the autofilter function to identify all matches to be played on Friday, Saturday and Sunday.
For each day I copy / paste all the matches to a seperate section on another sheet.
Everything works fine until there's no match to be played on one of the days mentioned above.
A message 'Run-time Error 1004, No cells were found' pops up and the script will stop.
I've been looking for solutions a couple of hours, but nothing seems to work.
Can anyone guide me into the right direction?
Basiscally what I want the script to do is when it doesn't find matches for friday it should continue to run and trying to find matches for saturday.
Thanks
Remco
Below is (part of) my script:
I'm the match secretary of our local football club. Each weekend I need to provide an overview of all matches to be played that weekend, showing which field, what time, etc.
I've build an excel sheet to generate this overview from an export from the special software we use to plan the matches.
My knowledge of VBA is quite limited but by browsing on forums, recording macros and looking at the code and some common sense I managed to build a script that does exactly what I want.
I'm using the autofilter function to identify all matches to be played on Friday, Saturday and Sunday.
For each day I copy / paste all the matches to a seperate section on another sheet.
Everything works fine until there's no match to be played on one of the days mentioned above.
A message 'Run-time Error 1004, No cells were found' pops up and the script will stop.
I've been looking for solutions a couple of hours, but nothing seems to work.
Can anyone guide me into the right direction?
Basiscally what I want the script to do is when it doesn't find matches for friday it should continue to run and trying to find matches for saturday.
Thanks
Remco
Below is (part of) my script:
VBA Code:
'Autofilter Home matches saturday
ActiveSheet.Range("A:Q").AutoFilter Field:=17, Criteria1:="home"
ActiveSheet.Range("A:Q").AutoFilter Field:=16, Criteria1:="saturday"
'Copy visible cells
Dim rSource As Range
Set rSource = Range("A1").CurrentRegion.Offset(1).Resize(, 13)
rSource.Resize(rSource.Rows.Count - 1).SpecialCells(xlCellTypeVisible).Copy
'Paste to sheet Home matches
Sheets("Home matches").Select
Range("A11").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
'Autofilter Home matches friday
Sheets("Voorbereiding").Select
ActiveSheet.Range("A:Q").AutoFilter Field:=17, Criteria1:="home"
ActiveSheet.Range("A:Q").AutoFilter Field:=16, Criteria1:="friday"
'Copy visible cells
Set rSource = Range("A1").CurrentRegion.Offset(1).Resize(, 13)
rSource.Resize(rSource.Rows.Count - 1).SpecialCells(xlCellTypeVisible).Copy
'Paste to sheet Home matches
Sheets("Home matches").Select
Range("A6").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
'Autofilter Home matches Sunday
Sheets("Voorbereiding").Select
ActiveSheet.Range("A:Q").AutoFilter Field:=17, Criteria1:="home"
ActiveSheet.Range("A:Q").AutoFilter Field:=16, Criteria1:="sunday"
'Copy visible cells
Set rSource = Range("A1").CurrentRegion.Offset(1).Resize(, 13)
rSource.Resize(rSource.Rows.Count - 1).SpecialCells(xlCellTypeVisible).Copy
'Paste to sheet Home Matches
Sheets("Home Matches").Select
Range("A39").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False