+ Reply to Thread
Results 1 to 3 of 3

help required on retrieving saved record and populating cells

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    11-22-2006
    MS-Off Ver
    2010
    Posts
    201

    help required on retrieving saved record and populating cells

    hi all, i posted earlier but i think my example was maybe too complicated to follow.
    i am posting a smaller spreadsheet which i hope is easier to follow:

    The user enters their details in th DataSheet page range B2:B5 the fills in the boxes underneath.

    In this example, 2 records have been saved into the STORAGE sheet for 1/5/2012 and 1/7/2012.

    My question is. Can a macro be set that would allow the user to enter data into section B2:B5 of the datasheet page and then retrieve all the data for that record, if it exists in Storage. ie: if it exists then the cells in DataSheet would be populated with the data.

    Possible complicating factor is that B23 is a drop down menu. Other drop downs exist in the full version.

    hope this is achievable.

    many thanks in advance
    Tinkerbelle x
    Attached Files Attached Files

  2. #2
    Registered User
    Join Date
    11-08-2006
    Location
    Sydney
    MS-Off Ver
    2010
    Posts
    37

    Re: help required on retrieving saved record and populating cells

    A macro to cross reference what the user enters with what is in Storage is not too complex.
    How do you plan to trigger the macro? Worksheet_Change event?

    Sub CheckStorage()
        
        Dim ukey As String
        Dim anchor As Range
        Dim rng As Range
        Dim c As Range
        
        Set anchor = Range("B2")
        ukey = anchor.Offset(0) & anchor.Offset(1) & anchor.Offset(2) & CLng(anchor.Offset(3)) ' Build the search key
        Set rng = Sheets("Storage").Columns("O:O") ' Define where to search
        Set c = rng.Find(what:=ukey, LookIn:=xlValues, lookat:=xlWhole) ' Check for a match
        If Not c Is Nothing Then ' Do whatever you want if a match is made
            ' code to populate datasheet goes here
        End If
        
    End Sub
    Regards, AB

  3. #3
    Forum Contributor
    Join Date
    11-22-2006
    MS-Off Ver
    2010
    Posts
    201

    Re: help required on retrieving saved record and populating cells

    Thanks for the reply AB. The macro will be triggered by a command button. ie: the user would enter their details in range B2:B5 of Datasheet and then press a button to populate the cells if that set of details had already been entered. Ideally, if they hadnt been entered then it would return a message box saying something like "No details found".
    many thanks for your help.

+ 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