+ Reply to Thread
Results 1 to 5 of 5

Sorting by variable keys

  1. #1
    Registered User
    Join Date
    03-22-2006
    Posts
    25

    Sorting by variable keys

    Hi,

    I have some code in a macro:

    Please Login or Register  to view this content.
    But, two things needs to be changed: the key (wich in my example is K:K) must be picked from a cell B4 (wich has variable content). And: order can be ascending and descending, depending on the value in B5 (1 or 2).

    How should I change this?
    Last edited by jgmiddel; 10-10-2008 at 09:30 AM.

  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
    Hello jgmiddel,

    It would help to have a little more information about the contents of cell B5. Will it be text like "K:K" or an actual range address like $K1:$k200? Also, what version of Excel is the code from?

    Sincerely,
    Leith Ross

  3. #3
    Registered User
    Join Date
    03-22-2006
    Posts
    25
    The content of B4 is the column, for example 'K:K', or 'D:D'. De value of B5 is 1 or 2. I am working in Excel 2007.

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

    You could code it this way...
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

  5. #5
    Registered User
    Join Date
    03-22-2006
    Posts
    25
    He, this works very fine! . Thanks a lot!

+ 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. Variable Cell Refence Problem
    By hankbug in forum Excel General
    Replies: 1
    Last Post: 09-17-2008, 05:19 PM
  2. Enter variable into popup box, variable defines cell
    By invisible777 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-31-2007, 06:31 PM
  3. Variable scope problem
    By tqm1 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-28-2007, 02:56 AM
  4. Dynamic variable state combinations
    By Mbrolass in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-24-2007, 05:48 AM
  5. static global variable?
    By fern in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-23-2007, 02:58 AM

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