RockandGrohl
Well-known Member
- Joined
- Aug 1, 2018
- Messages
- 810
- Office Version
- 365
- Platform
- Windows
Hi guys,
We have a sheet at work which is a very rudimentary tool to select adverts to run in local newspapers. What it does is display a list of 74 papers and then you select the row, click a macro button which opens an adselect window that displays a list of our products we can sell. We then select a couple products and commit the selections, this then takes the information and writes it to a file called "Advert Data 2018"
This should hopefully all make sense. Ok, so that's fine, you go through each paper 74 times and choose the 2 best adverts. With help of a very excellent member of this community we managed to bring together a process file that can look at each paper and determine the 2 best adverts based on a scoring criteria. This works excellently, but you had to input each paper in, then write down every possible product reference.
That process is done automatically via the macro behind the adselect button, and my boss, before he left on annual leave, quickly bodged together a rough 'n' ready macro that displays each paper and each tour reference like this:
[TABLE="width: 500"]
<tbody>[TR]
[TD]Paper[/TD]
[TD]Reference[/TD]
[/TR]
[TR]
[TD]Andover[/TD]
[TD]123F12[/TD]
[/TR]
[TR]
[TD]Andover[/TD]
[TD]181G18[/TD]
[/TR]
[TR]
[TD]Andover[/TD]
[TD]19FG73[/TD]
[/TR]
[TR]
[TD]Andover[/TD]
[TD]002R02[/TD]
[/TR]
</tbody>[/TABLE]
ETC ETC.
It then outputs them into a new sheet called "Full Output"
The problem:
While this process works really well, you essentially have to click each individual paper, click the ad-select button, wait 30 seconds for it to do its thing, then don't do any selections and close them. This process alone takes a good hour, is incredibly tedious and manual, and in my opinion it's redundant as the macro behind the adselect does everything for you - so it's possible to get the data, just not to format it the way you want automatically... yet.
What the macro does is read the paper and pull through every possible product for each paper, then when you click a new paper and click the adselect button, it appends the list with the new paper, so Andover, then you would do Braintree, then Cheltenham etc etc until you run through the entire list.
This is the VBA behind the process that outputs to the "Full Output" tab:
Sub Macro2()'
' Macro2 Macro
'
'
Columns("A:B").Select
ActiveWorkbook.Worksheets("Full Output").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Full Output").Sort.SortFields.Add Key:=Range( _
"A2:A51"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
ActiveWorkbook.Worksheets("Full Output").Sort.SortFields.Add Key:=Range( _
"B2:B51"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
With ActiveWorkbook.Worksheets("Full Output").Sort
.SetRange Range("A1:B51")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End Sub
And finally, this is what I want:
With my limited VBA knowledge, I know that macro isn't the whole story. It doesn't seem to reference where it needs to open which leads me to believe there's a "macro2" reference in another macro.
But essentially this is what I want.
Is it possible to append the Module2 macro to look for the next eligible paper in the list, open it, then close it?
Thanks.
We have a sheet at work which is a very rudimentary tool to select adverts to run in local newspapers. What it does is display a list of 74 papers and then you select the row, click a macro button which opens an adselect window that displays a list of our products we can sell. We then select a couple products and commit the selections, this then takes the information and writes it to a file called "Advert Data 2018"
This should hopefully all make sense. Ok, so that's fine, you go through each paper 74 times and choose the 2 best adverts. With help of a very excellent member of this community we managed to bring together a process file that can look at each paper and determine the 2 best adverts based on a scoring criteria. This works excellently, but you had to input each paper in, then write down every possible product reference.
That process is done automatically via the macro behind the adselect button, and my boss, before he left on annual leave, quickly bodged together a rough 'n' ready macro that displays each paper and each tour reference like this:
[TABLE="width: 500"]
<tbody>[TR]
[TD]Paper[/TD]
[TD]Reference[/TD]
[/TR]
[TR]
[TD]Andover[/TD]
[TD]123F12[/TD]
[/TR]
[TR]
[TD]Andover[/TD]
[TD]181G18[/TD]
[/TR]
[TR]
[TD]Andover[/TD]
[TD]19FG73[/TD]
[/TR]
[TR]
[TD]Andover[/TD]
[TD]002R02[/TD]
[/TR]
</tbody>[/TABLE]
ETC ETC.
It then outputs them into a new sheet called "Full Output"
The problem:
While this process works really well, you essentially have to click each individual paper, click the ad-select button, wait 30 seconds for it to do its thing, then don't do any selections and close them. This process alone takes a good hour, is incredibly tedious and manual, and in my opinion it's redundant as the macro behind the adselect does everything for you - so it's possible to get the data, just not to format it the way you want automatically... yet.
What the macro does is read the paper and pull through every possible product for each paper, then when you click a new paper and click the adselect button, it appends the list with the new paper, so Andover, then you would do Braintree, then Cheltenham etc etc until you run through the entire list.
This is the VBA behind the process that outputs to the "Full Output" tab:
Sub Macro2()'
' Macro2 Macro
'
'
Columns("A:B").Select
ActiveWorkbook.Worksheets("Full Output").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Full Output").Sort.SortFields.Add Key:=Range( _
"A2:A51"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
ActiveWorkbook.Worksheets("Full Output").Sort.SortFields.Add Key:=Range( _
"B2:B51"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
With ActiveWorkbook.Worksheets("Full Output").Sort
.SetRange Range("A1:B51")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End Sub
And finally, this is what I want:
With my limited VBA knowledge, I know that macro isn't the whole story. It doesn't seem to reference where it needs to open which leads me to believe there's a "macro2" reference in another macro.
But essentially this is what I want.
- Open the first paper which doesn't have "SKIP" in column F, in adselect window (this then copies the advert name and all possible products into Full Output tab)
- Close adselect window
- Find next paper which doesn't have "SKIP"
- Open this paper in adselect
- Close adselect window
- Repeat till the end of the list, then stop.
Is it possible to append the Module2 macro to look for the next eligible paper in the list, open it, then close it?
Thanks.