+ Reply to Thread
Results 1 to 11 of 11

Dependant Data Validation and Relative Referrence in Macros

  1. #1
    Registered User
    Join Date
    02-05-2014
    Location
    Kelowna, Canada
    MS-Off Ver
    Excel 2010
    Posts
    6

    Dependant Data Validation and Relative Referrence in Macros

    Hi,
    I am new to using Macros and data validation and have run into a problem i am hoping someone can help with.
    I am trying to create a macro for estimating purposes that will contain a dependent data validation. The dependent validation will work if i use a direct reference in the second validation
    =INDIRECT(SUBSTITUTE(I82," ","_"))
    This allows my second selection based on the first.
    The problem i have is i want this to run within a macro that can be inserted at any location in the sheet and so the I82 would need to be relative based on where i start. If i try
    =INDIRECT(SUBSTITUTE(R[-15]C," ","_"))
    I get an error as i am trying to run the macro.
    How would be the best way to achieve this?
    Thanks Damien

  2. #2
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,788

    Re: Dependant Data Validation and Relative Referrence in Macros

    Hi DamienPalmer,

    Welcome to the forum

    Can you please share your full code?

    When you post code please Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here


    If your problem is solved, then please mark the thread as SOLVED>>Above your first post>>Thread Tools>>
    Mark your thread as Solved


    If the suggestion helps you, then Click *below to Add Reputation

  3. #3
    Registered User
    Join Date
    02-05-2014
    Location
    Kelowna, Canada
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Dependant Data Validation and Relative Referrence in Macros

    Hi Sixthsense,

    Thank you for the reply

    The code for the data validation is as follows

    Please Login or Register  to view this content.
    The I82 is a reference to the following data validation

    Please Login or Register  to view this content.
    The drop down list in the first code would change based on if aggregate base or pedestal base is selected from the menu set in the second code.
    I would need to change the I82 to reference 15 rows up no matter where i start the macro.

    Is this enough info, or do you need the code for the whole macro?

    Thanks

    Damien

  4. #4
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,788

    Re: Dependant Data Validation and Relative Referrence in Macros

    Replace this

    Please Login or Register  to view this content.
    With

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    02-05-2014
    Location
    Kelowna, Canada
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Dependant Data Validation and Relative Referrence in Macros

    Hi Sixthsense,

    This is what i have now

    Please Login or Register  to view this content.
    The macro will run but the dropdown menu just displays FALSE. This is the same is i enter cell reference I82 in place of the R[-15]C

    Damien

  6. #6
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,788

    Re: Dependant Data Validation and Relative Referrence in Macros

    Delete this....

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    02-05-2014
    Location
    Kelowna, Canada
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Dependant Data Validation and Relative Referrence in Macros

    Hi Sixthsense,

    I tried deleting the bit of code you suggested and am left with this



    Please Login or Register  to view this content.
    When i try and run the macro it keeps giving me a Run-time error '1004'

    Damien
    Last edited by FDibbins; 02-07-2014 at 01:41 AM.

  8. #8
    Registered User
    Join Date
    02-05-2014
    Location
    Kelowna, Canada
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Dependant Data Validation and Relative Referrence in Macros

    Sorry, i thought i had put them in,


    Please Login or Register  to view this content.

    When i try and run the macro it keeps giving me a Run-time error '1004'

    Damien
    Last edited by FDibbins; 02-07-2014 at 01:41 AM.

  9. #9
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,788

    Re: Dependant Data Validation and Relative Referrence in Macros

    Its working fine for me

    Attach a sample workbook. Make sure there is just enough data to make it clear what is needed. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are demonstrated, mock them up manually if needed. Remember to desensitize the data.

    Click on GO ADVANCED and use the paperclip icon to open the upload window.

    View Pic

  10. #10
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    53,047

    Re: Dependant Data Validation and Relative Referrence in Macros

    Damien, you actually did put them in, but you made a tiny error in syntax (no biggie, I have seen the same thing before)

    You had [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] then your code, then ended with [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE]

    What you actually need is [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE]
    Theeasy way to do it is paste in your code, highlight it, then click the # button above (where the "bold/Italic/underline" etc is
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  11. #11
    Registered User
    Join Date
    02-05-2014
    Location
    Kelowna, Canada
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Dependant Data Validation and Relative Referrence in Macros

    Hi Sixthsense,

    I have attached the excel sheet with how it should look. It will work if i put an absolute reference in an run it from the same starting cell but i cannot run it from any where. There are some notes on the sheet to explain. Hope this helps!

    Damien
    Attached Files Attached Files

+ 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. Dependant data validation with dependant default value
    By JamesMeek in forum Excel General
    Replies: 2
    Last Post: 04-08-2013, 10:16 AM
  2. dependant data validation
    By ztg5003 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-23-2011, 09:16 AM
  3. Dependant Data Validation
    By rhlongo in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 01-05-2008, 12:32 PM
  4. Dependant? Data Validation
    By matrixskydiver in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 12-08-2007, 07:56 PM
  5. Dependant? Data Validation
    By matrixskydiver in forum Excel General
    Replies: 1
    Last Post: 12-08-2007, 08:10 AM

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