+ Reply to Thread
Results 1 to 12 of 12

NamedRange validation is working only when validated cell is choosen

  1. #1
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    NamedRange validation is working only when validated cell is choosen

    Hi,

    i have very serious issue.

    Code:

    Please Login or Register  to view this content.
    so generally idea is to check if validation is true or false in A1 in yellow field.
    I am using code like above (test macro) to check this.
    For this data validation i am using few named ranges combined with formulas in order to :
    1. get mapped regex pattern.
    2. get named range cell name.
    3. combine both within formula and return boolean.

    Generally i am importing all named ranges from CSV to main workbook and want to check if all fields are validated.
    Issue occurs when validation (complex one like in my example) is not on activesheet So first what i have to do is select A1 cell and run code (result: "True"). If i am on another worksheet - result will be "False".

    How can fix the issue without slowing general working of macro performance?

    Can anybody help?
    Best,
    Jacek
    Attached Files Attached Files
    Last edited by jaryszek; 07-15-2019 at 08:00 AM.

  2. #2
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,481

    Re: NamedRange validation is working only when validated cell is choosen

    Hi there,

    Without going into your code in detail, the first thing I would suggest investigating is the highlighted sections of the following code:

    Please Login or Register  to view this content.

    All of these refer to ranges on whichever worksheet happens to be active when your code is run, but it is much better to use fully-qualified references (e.g. Worksheets("SheetName").Range("RangeAddress")).


    Hope this helps - please let me know how you get on.

    Regards,

    Greg M

  3. #3
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: NamedRange validation is working only when validated cell is choosen

    Hi Greg,

    thank you.
    But i do not have worksheet name while importing CSV.

    Only named range so this is why i am using application.range property.
    Still this is not solving the issue...

    One workaround can be to retrieve worksheet name from named Range and refer directly but would be the best option?
    It will not slow the macro performance?

    Best,
    Jacek

  4. #4
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: NamedRange validation is working only when validated cell is choosen

    Anyone?

    Jacek

  5. #5
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: NamedRange validation is working only when validated cell is choosen

    hi,

    please advice,
    Jacek

  6. #6
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: NamedRange validation is working only when validated cell is choosen

    Hi,

    anyone?

    Only way to avoid this selection is to refer to worksheet directly using:

    Please Login or Register  to view this content.
    True?

    What with using application.goto ?
    Maybe this will solve?

    I tried to test but i got error.

    Jacek

  7. #7
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: NamedRange validation is working only when validated cell is choosen

    Please help,

    Jacek

  8. #8
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: NamedRange validation is working only when validated cell is choosen

    Ok i will stick method :

    Please Login or Register  to view this content.
    i do noth think so there is another workaround for this.

    Without selecting i have to refer exact to specific worksheet where named range is.

    I am not closing the topic - maybe somebody will help in the future.

    Best,
    Jacek

  9. #9
    Valued Forum Contributor
    Join Date
    02-02-2016
    Location
    Indonesia
    MS-Off Ver
    Office 365
    Posts
    1,004

    Re: NamedRange validation is working only when validated cell is choosen

    Hi, jaryszek
    I don't quite understand what you're trying to do.
    But if you want to get the sheet's name of a named range then you can use 'Parent.Name'.
    Something like this:

    Please Login or Register  to view this content.

  10. #10
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: NamedRange validation is working only when validated cell is choosen

    This is a problem about Akuini.

    I have CSV with all named ranges but without parent worksheet names.
    And excel is not referencing with application.range (sometimes does, sometimes not) when specific worksheet is not selected.
    So i have 2 options:

    1. Go to specific worksheet using application.goto property
    2. Add to csv worksheet name and use it with worksheets("sheet1") property.

    I do not think other solutions.

    Jacek

  11. #11
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: NamedRange validation is working only when validated cell is choosen

    Hi Guys,

    i have to refresh the topic.

    I am testing solution with this loop:
    Please Login or Register  to view this content.
    so i am looping through all named ranges and checking validations there.
    problem is when validation is false because in this line:

    If .Range(vName.Name).Validation.Value = False
    macro is stopping and exiting without any error!!!
    Only way to avoid this is to use application.goto method. So i have to open specific worksheet.

    Why this is working like that? How to catch this?
    Worksheets("Name") is not working...

    Please help,
    Jacek

  12. #12
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: NamedRange validation is working only when validated cell is choosen

    Ok Guys i found the problem.

    This is only when i am getting "Value#" in data validation lists...

    Jacek

+ 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. Replies: 1
    Last Post: 01-03-2019, 08:09 PM
  2. Automatically change validated entries when source of validation list changes
    By wallgreen1212 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-20-2017, 08:18 AM
  3. Automatically change validated entries when source of validation list changes
    By suchetherrah in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-29-2016, 11:58 AM
  4. Data validation list multiple options problem when entering none validated data
    By ThomasCarter in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-02-2012, 05:53 AM
  5. Validation Type Dependant on Validated List.
    By Dyskresiac in forum Excel General
    Replies: 1
    Last Post: 06-10-2010, 02:39 PM
  6. validation rules not working when someone copy paste data on validation cell
    By jthakrar in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 05-17-2010, 03:36 AM
  7. [SOLVED] be validated or not validated in a cell
    By x taol in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-21-2005, 09:40 PM

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