+ Reply to Thread
Results 1 to 6 of 6

Data Validation Question

  1. #1
    Joe
    Guest

    Data Validation Question

    Hi,

    I would like to know if I can "call in" data validation using a macro.

    I have a list in a certain worksheet, say Sheet "my list", and I want
    to add data validation to Column A in another sheet "status". I tried
    doing this manually, but then, when I run my parent macro for the
    project, I have the "Clearcontents" option in that (so that when the
    macro is run, it wont print out results for the previous run), and that
    seems to remove the data validation property in Col A.

    Can anyone help me with this? (I searched online, but most of the stuff
    I found is either out of context, or too abstruse for me - I'm a
    novice in VB programming, but am learning fast)

    Thanks a lot,

    Joe.


  2. #2
    ben
    Guest

    RE: Data Validation Question

    Columns("A:A").Select
    With Selection.Validation
    .Delete
    .Add Type:=xlValidateWholeNumber, AlertStyle:=xlValidAlertStop, _
    Operator:=xlBetween, Formula1:="00", Formula2:="55"
    .IgnoreBlank = True
    .InCellDropdown = True
    .InputTitle = ""
    .ErrorTitle = ""
    .InputMessage = ""
    .ErrorMessage = ""
    .ShowInput = True
    .ShowError = True
    End With

    this add validation to column "A" for a whole number from 00 to 55. you can
    edit any of the variable.
    This was created using the macro recorder. Try using that to get the exact
    validation you need, that way you can see proper Syntax









    --
    When you lose your mind, you free your life.


    "Joe" wrote:

    > Hi,
    >
    > I would like to know if I can "call in" data validation using a macro.
    >
    > I have a list in a certain worksheet, say Sheet "my list", and I want
    > to add data validation to Column A in another sheet "status". I tried
    > doing this manually, but then, when I run my parent macro for the
    > project, I have the "Clearcontents" option in that (so that when the
    > macro is run, it wont print out results for the previous run), and that
    > seems to remove the data validation property in Col A.
    >
    > Can anyone help me with this? (I searched online, but most of the stuff
    > I found is either out of context, or too abstruse for me - I'm a
    > novice in VB programming, but am learning fast)
    >
    > Thanks a lot,
    >
    > Joe.
    >
    >


  3. #3
    Joe
    Guest

    Re: Data Validation Question

    Thanks a lot, Ben. I have more questions now:

    1. What is a macro recorder? How can I access it?

    2. My list is a bunch of strings - not numbers. What would I have to
    change to the above macro to achieve that?

    Thanks,

    Joe.


  4. #4
    ben
    Guest

    Re: Data Validation Question

    in excel on the main menu acess the following menu

    Tools>Macros>Macro Recorder

    what this does is records Actions that your perform manually in Excel and
    writes them into VBA code in a module for you.

    So what you need to do is

    run the macro recorder
    setup your data validation
    stop the macro recorder

    Then in VBA editor, you should now have the proper syntax for the data
    validation you need.




    --
    When you lose your mind, you free your life.


    "Joe" wrote:

    > Thanks a lot, Ben. I have more questions now:
    >
    > 1. What is a macro recorder? How can I access it?
    >
    > 2. My list is a bunch of strings - not numbers. What would I have to
    > change to the above macro to achieve that?
    >
    > Thanks,
    >
    > Joe.
    >
    >


  5. #5
    Joe
    Guest

    Re: Data Validation Question

    Thanks a bunch, Ben!

    Joe.


  6. #6
    Pops Jackson
    Guest

    RE: Data Validation Question

    Ben,

    I have a routine which adds a new row at row3 for addition of new data. The
    routine includes the code listed below but has no effect. I even clicked
    "Data"/"Validation"etc. and applied the settings manually. They work for the
    row in question until the routine is run and then they move with the row of
    data to row4. The routine specifies row3 after the new row has been added so
    it should work but doesn't.

    Do you have a solution for this dilemma?

    Thanks,

    Jim
    --
    Pops Jackson


    "ben" wrote:

    > Columns("A:A").Select
    > With Selection.Validation
    > .Delete
    > .Add Type:=xlValidateWholeNumber, AlertStyle:=xlValidAlertStop, _
    > Operator:=xlBetween, Formula1:="00", Formula2:="55"
    > .IgnoreBlank = True
    > .InCellDropdown = True
    > .InputTitle = ""
    > .ErrorTitle = ""
    > .InputMessage = ""
    > .ErrorMessage = ""
    > .ShowInput = True
    > .ShowError = True
    > End With
    >
    > this add validation to column "A" for a whole number from 00 to 55. you can
    > edit any of the variable.
    > This was created using the macro recorder. Try using that to get the exact
    > validation you need, that way you can see proper Syntax
    >
    >
    >
    >
    >
    >
    >
    >
    >
    > --
    > When you lose your mind, you free your life.
    >
    >
    > "Joe" wrote:
    >
    > > Hi,
    > >
    > > I would like to know if I can "call in" data validation using a macro.
    > >
    > > I have a list in a certain worksheet, say Sheet "my list", and I want
    > > to add data validation to Column A in another sheet "status". I tried
    > > doing this manually, but then, when I run my parent macro for the
    > > project, I have the "Clearcontents" option in that (so that when the
    > > macro is run, it wont print out results for the previous run), and that
    > > seems to remove the data validation property in Col A.
    > >
    > > Can anyone help me with this? (I searched online, but most of the stuff
    > > I found is either out of context, or too abstruse for me - I'm a
    > > novice in VB programming, but am learning fast)
    > >
    > > Thanks a lot,
    > >
    > > Joe.
    > >
    > >


+ 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