+ Reply to Thread
Results 1 to 4 of 4

Macro to move horizontal data to vertical - in new sheet--excluding blank cells

  1. #1
    Registered User
    Join Date
    08-24-2012
    Location
    Littleton, CO
    MS-Off Ver
    Excel 2010
    Posts
    22

    Macro to move horizontal data to vertical - in new sheet--excluding blank cells

    Hi,

    I'm pretty much a rookie with Macros. Here's what I'm facing, hopefully I can find some direction (or even solutions!). End result: need Horizontal data moved to vertical in order to make it pivot friendly.

    I have a spread sheet with over possible 65,500 data points - Horizontal Format 410 rows, 174 columns

    --I want to create a macro that will populate a second sheet in a vertical format, but only specific rows/colums (specifically Column B, C, H13-FU13, H15-FU408).
    --If a particular cel (H13 for example) is not populated, I don't want it included in sheet 2 vertical format.

    I found the following code thanks to this site and have began personalizing it, but need assistance formatting to my needs. ANY help is greatly appreciated. One thing I've learned through posts is that the code - ThisCol = Mid("ABCDEFGHIJK", i, 1) - isn't friendly when dealing with more than 26 columns.

    The Excel file is too large, otherwise I'd attach it.

    THANKS TO ALL,
    Jackdaddy0711


    Please Login or Register  to view this content.

  2. #2
    Administrator JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Macro to move horizontal data to vertical - in new sheet--excluding blank cells

    Let's just address your problem with ThisCol variable. The problem stems from it later being used in a Range() syntax, which requires letter values for columns. Switch to the Cells() syntax and it lets you use column NUMBERS instead, eliminating the problem.

    Please Login or Register  to view this content.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Registered User
    Join Date
    08-24-2012
    Location
    Littleton, CO
    MS-Off Ver
    Excel 2010
    Posts
    22

    Re: Macro to move horizontal data to vertical - in new sheet--excluding blank cells

    Thanks Jerry. I'm sure that'll work once I get the rest of it figured out. Right now I get a "Invalid outside procedure" error. another question: I have named my sheets "Vendor Rate Card" and "Vertical"... there are also "Sheet1" & "Sheet2" references in the macro -- is it proper to refer to the sheet/tab names or will sheet1/sheet2 suffice?

  4. #4
    Administrator JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Macro to move horizontal data to vertical - in new sheet--excluding blank cells

    Invalid Outside procedure means you pasted the "snippet" above into a module somewhere that is not between SUB/END SUB headers and footers.

    Please Login or Register  to view this content.

    How to address specific sheetnames is "design" decision. If a group of sheets are referenced off and on all through the lines of code to follow should, I pay be tempted to declare sheet variables at the top of the macro, then refer them all through the code by the variable object. This makes it easy to change those sheet names later in one place at the top and those new sheet names flow down into the code with no additional edits.


    Please Login or Register  to view this content.

    Another trick is to mention a sheet once then let a bunch of lines of code that follow all link to that sheet by using leading "dots" on those lines of code. This again allows the sheet names to edited in fewer places if ever need be:

    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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