VBA: help needed to display data in rows, not columns

webanalytics40

New Member
Joined
Oct 22, 2015
Messages
1
Hi,

I have built a macro which loops through data from one sheet ("Sheet1") to build a URL (it's an API for the web analytics tool Webtrends). The macro then loads data from the API into a new sheet "display". Each dataset has the same 4 headers: Time Period, Page, Title, Page Views.

My issue is that the looped data is being displayed along columns (horizontally), but I need the data to display row after row (vertically).

The result I want is just 4 columns being filled with hundreds of rows of data, as opposed to hundreds of columns being filled with just a couple of rows of data. Transposing seems to just paste everything under one column.

Here is my code:

Sub ConcatTest()

Dim rCell As Range

For Each rCell In Sheet1.Range("F2", Sheet1.Cells(Sheet1.Rows.Count, "F").End(xlUp))

With Sheets("display").QueryTables.Add(Connection:= _
"URL;https://ws.webtrends.com/v3/Reporting/profiles/17716/reports/oOEWQj3sUo6/?totals=all&start_period=" & rCell & "&measures=1&format=html&suppress_error_codes=true", _
Destination:=Worksheets("display").Range("A1").End(xlUp)(2, 1))


.BackgroundQuery = True

.TablesOnlyFromHTML = True

.Refresh BackgroundQuery:=False

.SaveData = True

End With

Next rCell

End Sub


Can any body see why in this code my data is looping through columns as opposed through rows?

Thanks in advance!
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.

Forum statistics

Threads
1,215,943
Messages
6,127,826
Members
449,411
Latest member
adunn_23

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