+ Reply to Thread
Results 1 to 4 of 4

Creating variables based on cell location

  1. #1
    Registered User
    Join Date
    10-10-2009
    Location
    Leeds, England
    MS-Off Ver
    Excel 2007
    Posts
    2

    Creating variables based on cell location

    Hi all,

    A novice VBA programmer here! I am attempting to write a macro which is essentially populating an Excel 2007 spreadsheet through stochastic simulation. I need to log the number of times a cell is activated, under each of four contexts.

    So essentially, if Row i Column j is activated then a corresponding variable Aij, Bij, Cij or Dij would be created (if not already existing), or cumulated by 1.

    The problem as I see it - completely generalised - is to create a variable where the variable name itself is formulaic, as well as its value. I know SAS would have no problem with this due to the order in which it parses data steps, but I'm pretty amateur with other programming languages so I don't know if this is blindingly obvious or downright impossible!

    Thanks very much in anticipation of your help!
    Last edited by length; 10-11-2009 at 01:11 PM.

  2. #2
    Valued Forum Contributor Shijesh Kumar's Avatar
    Join Date
    05-26-2008
    Location
    Bangalore / India
    MS-Off Ver
    2000
    Posts
    717

    Re: Creating variables based on cell location

    Modify the code as per ur need
    Please Login or Register  to view this content.

  3. #3
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Creating variables based on cell location

    Shijesh,

    In Excel 2003, that would be a 33MB array. In Excel 2007, which the OP is using, it would be 34GB array.

    Length, another way would be to use a separate sheet:
    Please Login or Register  to view this content.
    Entia non sunt multiplicanda sine necessitate

  4. #4
    Registered User
    Join Date
    10-10-2009
    Location
    Leeds, England
    MS-Off Ver
    Excel 2007
    Posts
    2

    Re: Creating variables based on cell location

    Thanks guys,

    Four additional sheets (one per count variable) is a pretty neat solution which would certainly work - and probably be the better option for spreadsheets requiring thousands of rows and columns...For this purpose, I've modified the array code suggested by Shijesh (as I do not need every available cell so size isn't an issue).

    Cheers

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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