+ Reply to Thread
Results 1 to 10 of 10

Display data horizontally not vertically through VBA

  1. #1
    Registered User
    Join Date
    10-22-2015
    Location
    London, England
    MS-Off Ver
    2010
    Posts
    5

    Display data horizontally not vertically through VBA

    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:

    Please Login or Register  to view this content.
    Can any body see why in this code my data is looping through columns as opposed through rows?

    Thanks in advance!
    Last edited by Leith Ross; 10-22-2015 at 12:57 PM. Reason: Changed Color Tags to Code Tags

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Display data horizontally not vertically through VBA

    Hello webanalytics1,

    Welcome to the Forum!

    I think I understand what you are saying. To be sure, can you post an example of the output?
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Registered User
    Join Date
    10-22-2015
    Location
    London, England
    MS-Off Ver
    2010
    Posts
    5

    Re: Display data horizontally not vertically through VBA

    Thanks Leith!

    Here's a screenshot of the output. As you can see the tables loop in columns not rows. Let me know if you need any more information!Output example - data appearing horizontally.png

  4. #4
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,879

    Re: Display data horizontally not vertically through VBA

    Hi and welcome to the forum

    Pictures are of little value. Honestly, no one wants to re-type your data to try and solve your issue. Additionally, we would only be guessing at how your data was structured, ie. formulas, formatting, etc.

    Please attach a sample file that represents what you have. The structure of your attachment should be the same structure as your actual data. Any proprietary information should be changed.

    Include in the attachment any code you're currently using (whether it works or not) and an "After" of what you wish the output to be.

    To attach a file to your post,
    click advanced (next to quick post),
    scroll down until you see "manage file",
    click that and select "add files" (top right corner).
    click "select files" find your file, click "open" click "upload" click 'done" bottom right. click "submit reply"

    Once the upload is completed the file name will appear below the input boxes in this window.
    You can then close the window to return to the new post screen.
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  5. #5
    Registered User
    Join Date
    10-22-2015
    Location
    London, England
    MS-Off Ver
    2010
    Posts
    5

    Re: Display data horizontally not vertically through VBA

    Hi Alan, thanks for reaching out too.

    I have attached a sample of this macro, and the Macro is 'ConcatTestSampleVersion'. I used some API from the internet -http://wefeelfine.org/api.html (as my data is proprietary and requires login credentials).

    I created a new sheet titled 'After' to show you how I want the data to appear (the example content is from We Feel Fine API).

    The VBA code is the same, I've just replaced the URL: Sub ConcatTestSampleVersion()

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by alansidman; 10-23-2015 at 09:14 AM.

  6. #6
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Display data horizontally not vertically through VBA

    Hello webanalytics1,

    From the workbook, it appears you are importing only text. If that is the case, another method can be used to import the web table data, provided the page layout is the same for each web page.

    Can you provide me the URL you are using and some data to concatenate to it?

  7. #7
    Registered User
    Join Date
    10-22-2015
    Location
    London, England
    MS-Off Ver
    2010
    Posts
    5

    Re: Display data horizontally not vertically through VBA

    Hi Leith,

    I'm afraid I can't provide the URL as it's internal company and can't be shared publicly. If it's of any use I got most of the VBA coding from here: https://forums.webtrends.com/webtren...-18uhjdthw5wv9.

    Do you have any suggestions I could try out, then feedback to you if I get any errors or it works?

  8. #8
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Display data horizontally not vertically through VBA

    Hello webanalytics1,

    A VBA web query will return the data from its source as it is arranged in the table. Since your data is being flipped horizontally, the API you are using might be the problem. Have you checked your API code to be sure all variables and arguments are correct?

  9. #9
    Registered User
    Join Date
    10-22-2015
    Location
    London, England
    MS-Off Ver
    2010
    Posts
    5

    Re: Display data horizontally not vertically through VBA

    Hi Leith,

    I have updated the API code to ensure all variables have been included.

    I've also changed my VBA code, so I am no longer concatenating the URL in VBA. Instead, the code just pulls the URL from column H in 'Sheet 1' and loads the data in 'display'.

    The issue now is trying to loop this query. I will have an indefinite number of the API URLs listed in column H, 'Sheet 1', and I would like all data to load in one sheet, 'display'.

    Below is my new code. Do you have any suggestions as to how to loop it? My query isn't working:

    Please Login or Register  to view this content.

  10. #10
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,879

    Re: Display data horizontally not vertically through VBA

    Code Tags Added
    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found at http://www.excelforum.com/forum-rule...rum-rules.html



    (Because you are new to the forum, I have added them for you today. Please take a few minutes to read all Forum Rules and comply in the future.)

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] transpose and consolidate data horizontally to vertically
    By Excel_learner in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 06-04-2014, 03:50 PM
  2. [SOLVED] listbox display vertically and not horizontally
    By Blackbeginnings in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-18-2013, 07:03 PM
  3. Replies: 5
    Last Post: 01-27-2013, 09:36 PM
  4. Excel 2007 : Merging data horizontally vs. vertically
    By enhydra in forum Excel General
    Replies: 4
    Last Post: 12-12-2010, 06:16 PM
  5. UDF to Display Results Vertically Instead of One Cell Horizontally
    By snake10 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-13-2008, 12:18 PM
  6. Replies: 2
    Last Post: 02-14-2005, 01:48 AM
  7. A tough one! line up vertically/horizontally through data
    By djvice in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-14-2005, 04:32 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1