Consulting

Results 1 to 12 of 12

Thread: Validating values of a column in a file from another file

  1. #1
    VBAX Regular
    Joined
    May 2008
    Location
    India
    Posts
    35
    Location

    Smile Validating values of a column in a file from another file

    Dear Friends & Gurus,

    I have some 50-60 files in which data entry is done by individual users. I have a shared workbook (LISTS.XLS) - (sheet named ADMIN) - in which the data already available as follows:

    colA / ColB
    (Branch) / (Code)
    IVA / 5587
    IVA / 8788
    VC / 6783
    VC / 7329
    VC / 9283
    VB / 2638
    IVA / 4792
    IVA / 6879
    ..... ColB consist unique values. There is no repitition.

    I have a set of files which are named after the values of the colA of Lists.xls - (i.e. I have files like VB.XLS, IVA.XLS, VC.XLS, and so on).

    Now I am to enter data in a file named IVA. It has some 80-90 columns. Among these, first I am to enter the CODE. When I am entering the code in colA) in this file, it should check:

    1) In lists.xls file (in sheet named Admin) whether the ColA is equivalent to the file name of dataentry is being done.
    2) If the file name is right, then it should check whether the entered value is there in colB of Admin sheet of lists.xls.

    I attached a ZIP file, in which 3 files are there, and explained the requirement.

    I hope, someone will come forward to help me to find out the solution.

    The help is highly appreciated.

    acsishere.

  2. #2
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,060
    Location
    While you are waiting for a responce from the Guru's, please look up the following items in Excel's help ISError, Index, & Match. Using a combination of these may be what you are looking for.
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  3. #3
    VBAX Regular
    Joined
    May 2008
    Location
    India
    Posts
    35
    Location
    Dear Sir,

    Yes, I can try for that. But, I need to initiate a macro whenever the files are opened. Besides, the number of files are also more. If it could be a macro, then it will be easier for me to copy and initiate it at the time of opening the file. And if it is formula based, then every time the rows with formulas are to be dragged.

    Hence, I felt that a macro will be the easier and efficient way of tackling this problem.

    Thanks for the help in advance.

    acsishere.

  4. #4
    VBAX Regular
    Joined
    May 2008
    Location
    India
    Posts
    35
    Location
    Dear Friends,

    Any help is highly appreaciated.

    acsishere.

  5. #5
    VBAX Regular
    Joined
    May 2008
    Location
    India
    Posts
    35
    Location
    Dear Friends,

    I am very much in need of the solution.

    Thanks in advance.

    acsishere.

  6. #6
    VBAX Regular
    Joined
    May 2008
    Location
    India
    Posts
    35
    Location

    Smile Dear Friends,

    I am very much in need of a help?

    Any one please??

    Thanks in advance.

    acsishere.

  7. #7
    VBAX Regular
    Joined
    May 2008
    Location
    India
    Posts
    35
    Location
    Dear Friends,

    Any problem in my explanation or Is it not possible to do?

    I hope someone will come forward to help me.

    Thanks in advance.

    acsishere.

  8. #8
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    [VBA]Option Explicit
    Private Sub Worksheet_Change(ByVal Target As Range)
    Dim WB As Workbook, WS As Worksheet
    Dim Branch As String, ThsBk As String
    Dim c As Range, Lists As String
    Lists = "C:\BBB\Lists.xls" '<--- Change to suit

    If Target.Column <> 1 Then Exit Sub
    If Target.Cells.Count > 1 Then Exit Sub

    Application.ScreenUpdating = False
    ThsBk = Split(ActiveWorkbook.Name, ".")(0)
    Set WB = Workbooks.Open(Lists, , True)
    Set WS = WB.Sheets("Admin")
    Set c = WS.Columns(2).Find(Target)
    If Not c Is Nothing Then
    Branch = c.Offset(, -1)
    If ThsBk = c.Offset(, -1) Then
    Target.Offset(, 1) = "OK"
    Else
    Target.Offset(, 1) = "It is of " & Branch & " branch."
    End If
    Else
    Target.Offset(, 1) = "The value is wrong."
    End If
    WB.Close
    Application.ScreenUpdating = True
    End Sub
    [/VBA]
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  9. #9
    VBAX Regular
    Joined
    May 2008
    Location
    India
    Posts
    35
    Location

    Smile Dear Mr. mdmackillop,

    Thanks a lot for your code. It works great.

    Sir, can you please help me to do few enhancements.

    1) In macro, Messages in next column are shown like this:
    Target.Offset(, 1) = "It is of " & Branch & " branch."
    INSTEAD, all messages are to be shown in a message box to convey the concerned message. If the code is not available/or of another branch, the same cell should be activated in which the data entry is done. OR, If the data is correct or OK then the next column (of same row) should be selected.

    2) In the sheet where we enter the data, if the code is already exist in the same sheet, then it should say in a MsgBox that the code is already entered in this sheet.

    I seek your kind guidance for the same.

    Thanks in advance.

    acsishere.

  10. #10
    VBAX Regular
    Joined
    May 2008
    Location
    India
    Posts
    35
    Location

    Smile Dear Sir,

    Please help me to find out the solution.

    Thanks a lot in advance.

    acsishere.

  11. #11
    VBAX Regular
    Joined
    May 2008
    Location
    India
    Posts
    35
    Location

    Smile Dear Sir,

    Can any one please help me to find the solution?

    Thanking you and anticipating your expertise,

    acsishere.

  12. #12
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •