+ Reply to Thread
Results 1 to 12 of 12

Having cells change their contents according to what the contents of other cells are

  1. #1
    Registered User
    Join Date
    01-17-2008
    Posts
    21

    Having cells change their contents according to what the contents of other cells are

    I have a column in my .XLS whose contents I want to change depending on what the contents of the cells of a different column are. However, I only want two cells from the same row to be dependent on each other. So, for example, if $A$1 reads "1" then $B$1 should read "apple" and if $A$2 reads "1" then $B$2 should read "apple"; if $A$12 reads "3" then $B$12 should read "pavement" etc.

    Any help would be appreciated!

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    I think you need to look at one of these Functions - VLOOKUP or CHOOSE.

    See

    http://www.excel-it.com/excel_functions.htm
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Registered User
    Join Date
    03-24-2008
    Location
    Calabar, Nigeria
    MS-Off Ver
    2003, 2007
    Posts
    37
    I hope you are familiar with VBA. Copy and paste the following code in the code module for the sheet you are working with (right click the sheet tab and select 'View Code'). Change the X_ and Y_ Values correspondingly as desired. You may also change the column index for the X_ and Y_Values by changing the const declaration values of lX_Col and lY_Col

    Please Login or Register  to view this content.
    Last edited by nsenor udofa; 03-25-2008 at 08:24 AM.

  4. #4
    Registered User
    Join Date
    01-17-2008
    Posts
    21
    Thanks for the help

  5. #5
    Registered User
    Join Date
    01-17-2008
    Posts
    21
    Edit: NVM, see this.
    Last edited by I Am Herenow; 03-25-2008 at 12:27 PM.

  6. #6
    Registered User
    Join Date
    03-24-2008
    Location
    Calabar, Nigeria
    MS-Off Ver
    2003, 2007
    Posts
    37

    Creating Hyperlinks in Excel VBA etc.

    This is the code for your worksheet that I think you need.

    The validation on activation will help you or your user select the proper text.
    In addition to the X_ and Y_ value functions, the Link_Values function is also introduced to hold the hyperlink addresses. The Y_Links are derived from the title of the link web pages.

    I hope you understand the logic. ENJOY!

    Please Login or Register  to view this content.
    Last edited by nsenor udofa; 03-26-2008 at 06:02 AM.

  7. #7
    Registered User
    Join Date
    01-17-2008
    Posts
    21
    Thanks for the help, but at the moment "Private Function Link_Values()" all shows up red and it gives me a syntax error when I try to use the code.

  8. #8
    Registered User
    Join Date
    03-24-2008
    Location
    Calabar, Nigeria
    MS-Off Ver
    2003, 2007
    Posts
    37
    Add a double quote to the begining of line 5 of the procedure. Or copy and paste the code again. I have corrected the error.

  9. #9
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    I can't see why you need VBA to do this. A simple VLOOKUP or CHOOSE would work.

  10. #10
    Registered User
    Join Date
    03-24-2008
    Location
    Calabar, Nigeria
    MS-Off Ver
    2003, 2007
    Posts
    37
    Except for very simple situation, i prefer code behind objects to formulas. I believe it hides implementation from the user and make the objects easier to use. Is there a disadvantage to this for Excel?

  11. #11
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Quote Originally Posted by nsenor udofa
    Except for very simple situation, i prefer code behind objects to formulas. I believe it hides implementation from the user and make the objects easier to use. Is there a disadvantage to this for Excel?
    VBA will only work if macros are enabled
    Excel's Functions are generally faster than UDFs.
    Why re-invent the wheel?

  12. #12
    Registered User
    Join Date
    03-24-2008
    Location
    Calabar, Nigeria
    MS-Off Ver
    2003, 2007
    Posts
    37
    Quote Originally Posted by royUK
    VBA will only work if macros are enabled
    Excel's Functions are generally faster than UDFs.
    Why re-invent the wheel?
    Of course Excel functions are faster than UDFs!

    But I am talking about code behind object - Responding to user input to change parameters and cell values.

    In my experience, if you have a lot of calculations to perform (like 1000 long formulas in col 2 cells dependent on adjacent col 1 cells etc) and you are comfortable with VBA, using a worksheet_change event routine for your calculation and targeting col 1 is about 1000 times faster than Excel functions that all 1000 are likely to recalculate at every change in cell value if you don't want to loose interim accuracy.

    Think about it.

    ps. enabling macro is not such a big deal, is it?
    Last edited by nsenor udofa; 03-27-2008 at 06:03 AM.

+ 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