+ Reply to Thread
Results 1 to 2 of 2

Excel 2007 : VBA--display a variable's contents if its name corresponds to the value in a cell

  1. #1
    Registered User
    Join Date
    09-29-2010
    Location
    Provo, UT
    MS-Off Ver
    Excel 2007
    Posts
    1

    Question VBA--display a variable's contents if its name corresponds to the value in a cell

    I'm trying to paste variable values into a spreadsheet. I want to select which variable's value to paste by whether or not the column heading (or text in a given cell) is the NAME of that variable.

    So, for example:

    Say there are three variables in a VBA subprocedure: Title, Amount, and Total--each of which have stored values.

    In a worksheet, I have column headings entitled "Title" "Amount" and "Total" in say cells A1, B1, and C1, respectively.

    In a VBA subprocedure, I want to systematically go through row 1, column by column, check the text/value of that row, and dynamically select the variable with the same name as the text/value of the cell in the header and paste its values below the header in row 2.

    Maybe this is a bad setup, and I know this is unorthodox, but surely some cool Excel Guru knows how to solve this.

  2. #2
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,164

    Re: VBA--display a variable's contents if its name corresponds to the value in a cell

    Give us a sample workbook with a few sheets in it that explains the problem.
    Is Sheet1 the place these values get transfered to?
    Are all the numbers on Sheet2 directly below the words Title, Amount, Total?
    Are there multiple rows that have Title, Amount, Total with numbers below them?

    The code isn't that hard if you can show what your data looks like.

+ 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