Amending Date Range In a Formula From A Macro-UserForm

amish_z

New Member
Joined
Mar 5, 2015
Messages
13
Hi

So I will explain in more details, the following formula downloads data from Google Analytics for a certain period :

=Dump(GoogleAnalytics("ga:XXXXXXX","ga:adCost,ga:impressions,ga:adClicks,ga:CTR,ga:CPC,ga:goal7Completions","2015-02-03","2015-03-04","ga:campaign","","ga:medium==cpc;"",1,5000,FALSE,FALSE))

I want to create a button that can look up new date ranges I type in cells and enter them into the formula above, replacing the dates currently in it.

I will be entering the new date ranges in cells "A5" for start date and "A7" for end date.

I know it's quite a complex idea, but if any1 can help I'd be very grateful :)
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
Hi don't have the add-in so can't test, but maybe this will work for you.

Rich (BB code):
=Dump(GoogleAnalytics("ga:XXXXXXX","ga:adCost,ga:impressions,ga:adClicks,ga:CTR,ga:CPC,ga:goal7Completions",TEXT(A5,"YYYY-MM-DD"),TEXT(A7,"YYYY-MM-DD"),"ga:campaign","","ga:medium==cpc;"",1,5000,FALSE,FALSE))
 
Upvote 0
Hi don't have the add-in so can't test, but maybe this will work for you.

Rich (BB code):
=Dump(GoogleAnalytics("ga:XXXXXXX","ga:adCost,ga:impressions,ga:adClicks,ga:CTR,ga:CPC,ga:goal7Completions",TEXT(A5,"YYYY-MM-DD"),TEXT(A7,"YYYY-MM-DD"),"ga:campaign","","ga:medium==cpc;"",1,5000,FALSE,FALSE))


It tells me that line of code is a Syntax Error, not sure what to do about that...
 
Upvote 0
Like I say - difficult to test without the add-in. Do you have a link to the site where you got it from (assuming it's free!)? Does your original formula (in post#1) work?

Second attempt - again not tested.
Code:
=Dump(GoogleAnalytics("ga:XXXXXXX","ga:adCost,ga:impressions,ga:adClicks,ga:CTR,ga:CPC,ga:goal7Completions",TEXT(A5,"YYYY-MM-DD"),TEXT(A7,"YYYY-MM-DD"),"ga:campaign","","ga:medium==cpc;",1,5000,FALSE,FALSE))
 
Upvote 0
My original formula works fine, it seems as soon as I change it with something that is not actual dates, it throws up the syntax.

I downloaded the Add-In and if I copy and paste the formula from post#1 into Excel I get a syntax error. Can you check that it copy and pastes (directly from the forum) for you?

Having said that - the Add-In has some examples workbooks and it seems that you should be able to simply replace the hard coded dates with the cell references that contain your dates (A5 and A7) - no need for the TEXT() function.
 
Upvote 0
Ok so I've nearly got it working!

I am using this in my Macro :

ActiveCell.FormulaR1C1 = _
"=Dump(GoogleAnalytics(""ga:1169833"",""ga:adCost,ga:impressions,ga:adClicks,ga:CTR,ga:CPC,ga:goal7Completions"",A307,A306,""ga:campaign"","""",""ga:medium==cpc;ga:campaign!=(not set);ga:campaign!=ZZZ_Old_Mexico"","""",1,10000,FALSE,FALSE))"

This formula works fine in Excel but when it runs through the Macro, it amends the A307 to 'A307' - which the Add-in does not recognise.

How can I get VBA to not add ' to the cell I am using?
 
Upvote 0

Forum statistics

Threads
1,215,381
Messages
6,124,614
Members
449,175
Latest member
Anniewonder

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