Macros no longer working properly

MrBurn5

New Member
Joined
Jul 4, 2016
Messages
48
I'm stumped.

I recorded a macro last year that would pull statistics every week for me and it worked fine all season long, but when I ran it this year it wasn't "pasting" the data. Being on a mac, the best way I found to record these was to use "Get external data => Run saved query".

I re-recorded a new macro and during the recording process everything works just fine - all the data promptly is spit in to the worksheet. However when I save the book and then try to run the macro, it again - out of the blue - is not pasting the data in to the cells.

I am a novice with VBA so I don't know why it's doing this, nor do I know why it just spontaneously stopped working the way it should.

Does anyone have any thoughts on this? Would it easier to paste the code?
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
This makes no sense to me. On a hunch I tried something and it worked. I still don't understand why all of the sudden it stopped working but here's the scoop... This is a small piece of the original code from the original macro. This is the result of following some youtube videos and recording a macro, not writing one from scratch.

What was being recorded was getting the data from a saved query (link from the txt file is at the top and it came from the query two lines below titled NCAA6o.iqy). It was running completely fine like this up until I tried it yesterday.

I looked at some code from other people and noticed they didn't have the .PostText = line in their code so I went back and deleted all of those out of the macro and now it seems to be running fine.

So the new question is: Why did it stop working?


With ActiveSheet.QueryTables.Add(Connection:= _
"URL;https://www.teamrankings.com/college-football/stat/yards-per-rush-attempt" _
, Destination:=Range("AT4"))
.PostText = "ncaa6o.iqy" <==== Why is this the culprit?
.Name = False
.FieldNames = False
.RefreshStyle = xlInsertDeleteCells
.RowNumbers = False
.FillAdjacentFormulas = False
.HasAutoFormat = True
.RefreshOnFileOpen = 1
.BackgroundQuery = False
.TablesOnlyFromHTML = True
.SaveData = True
.Refresh BackgroundQuery:=False
.UseListObject = False
End With
 
Upvote 0

Forum statistics

Threads
1,223,897
Messages
6,175,271
Members
452,628
Latest member
dd2

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