+ Reply to Thread
Results 1 to 18 of 18

VBA - Match formulae to enter data on a pre-existing row using a form entry

  1. #1
    Registered User
    Join Date
    03-16-2016
    Location
    London
    MS-Off Ver
    2013
    Posts
    34

    VBA - Match formulae to enter data on a pre-existing row using a form entry

    Hey all,

    Really hoping someone can assist.

    Basically I am running a spreadsheet to collate date through a variety of user forms. Now I have the challenge of adding to a pre-existing row using a unique value (in column A)

    Specifically I am compiling a note, 25 columns across from a unique reference in my "Master" sheet within column A and then moving along one row at a time to add data. However I'm struggling to get going with this one.

    Sheets("Master").Select
    Range("A1").Select
    If ActiveCell.Value = "" Then
    Application.WorksheetFunction.Match(TextBox9.Value, Worksheets(1).Range("A4:A60000"), 0)
    ActiveCell.Offset(0, 25).Select
    ActiveCell.Value = TextBox4

    Any help would be greatly appreciated

    Thanks
    Michael

  2. #2
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,468

    Re: VBA - Match formulae to enter data on a pre-existing row using a form entry

    Hi Michael,

    Any chance we could see a sample workbook. It would make it far easier to understand your need here.

    BSB

  3. #3
    Registered User
    Join Date
    03-16-2016
    Location
    London
    MS-Off Ver
    2013
    Posts
    34

    Re: VBA - Match formulae to enter data on a pre-existing row using a form entry

    Hi BSB

    I've attached a sample workbook for you, Book1. The idea is, columns A to U have been populated with a macro using a user form already, therefore I have a new user form to collate columns B to Z (In green) and I am inserting data based of the unique filed in column A. Two user forms are required.

    Therefore I need help with a match formulae whereby details in, for example text box 4match to a unique ID in column A and I can program the response in the relevant column, x number of spaces along.

    Many thanks
    Michael
    Attached Files Attached Files

  4. #4
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,468

    Re: VBA - Match formulae to enter data on a pre-existing row using a form entry

    So you have a separate userform with fields that will be used to populate columns V - Z? And you want the row to update to be identified by matching a UID in a field on the same userform against column A?

    BSB

  5. #5
    Registered User
    Join Date
    03-16-2016
    Location
    London
    MS-Off Ver
    2013
    Posts
    34

    Re: VBA - Match formulae to enter data on a pre-existing row using a form entry

    Yes, you have it in one

  6. #6
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,468

    Re: VBA - Match formulae to enter data on a pre-existing row using a form entry

    I've added a simple userform to the attached for demonstration purposes. TextBox1 is for the Patient ID. TextBox2 - 5 is for the other details for columns V - Z.

    Simple code that sits behind the Submit button on the form is:
    Please Login or Register  to view this content.
    Should be straightforward enough to adapt to your workbook.
    Shout if you need more help.

    BSB
    Attached Files Attached Files

  7. #7
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,468

    Re: VBA - Match formulae to enter data on a pre-existing row using a form entry

    Here is another method using OFFSET you may prefer:
    Please Login or Register  to view this content.
    BSB

  8. #8
    Registered User
    Join Date
    03-16-2016
    Location
    London
    MS-Off Ver
    2013
    Posts
    34

    Re: VBA - Match formulae to enter data on a pre-existing row using a form entry

    Hey BSB

    This really did work a treat! Just a quick one with this, if I have a list box, rather than a text box, how can I modify the above string to bring a ListBox in one cell? For example TextBox4 could be ListBox4?

    Thanks
    Michael

  9. #9
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,468

    Re: VBA - Match formulae to enter data on a pre-existing row using a form entry

    Is the listbox a single selection or multiple
    selection?

    Which of the fields does the listbox pertain to?

    BSB

  10. #10
    Registered User
    Join Date
    03-16-2016
    Location
    London
    MS-Off Ver
    2013
    Posts
    34

    Re: VBA - Match formulae to enter data on a pre-existing row using a form entry

    Morning BSB

    Thanks for your assistance, the listbox is a multiple selection, my example didn't;t go into this much detail.
    What I have built is two list boxes whereby one contains all the options the second the single or multiple selection. The idea is that the second ListBox contains the results for the PatID in one cell as a summary. Is this something that is possible on your string of code?

    Many thanks
    Michael

  11. #11
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,468

    Re: VBA - Match formulae to enter data on a pre-existing row using a form entry

    I'm not sure I understand. Could you post a sample workbook with your userform included so we can see exactly what you mean?

    BSB

  12. #12
    Registered User
    Join Date
    03-16-2016
    Location
    London
    MS-Off Ver
    2013
    Posts
    34

    Re: VBA - Match formulae to enter data on a pre-existing row using a form entry

    Hi BSB

    Please see the attached extract workbook.

    Basically this is the beginning of another form which is being used with your coding above. The issue I'm faced with is multiple selections which appear in one ListBox, and how to insert these into the right row based on the unique ID

    Many thanks, your help is very much appreciated
    Michael
    Attached Files Attached Files
    Last edited by Mlanger575; 10-30-2016 at 10:41 AM.

  13. #13
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,468

    Re: VBA - Match formulae to enter data on a pre-existing row using a form entry

    Quote Originally Posted by Mlanger575 View Post
    The issue I'm faced with is multiple selections which appear in one ListBox, and how to insert these into the right row based on the unique ID.
    I assume you mean ListBox2 contents will be submitted to the sheet(?)
    If so, in which columns?

    There are currently a max of 4 items in the ListBox. Does each have a specific column to go to? i.e. option 1 will go to column A and option 2 will go to column B etc.? OR, would the first option selected go to column A and the second selected go to column B, even if these were options 3 and 4?

    BSB

  14. #14
    Registered User
    Join Date
    03-16-2016
    Location
    London
    MS-Off Ver
    2013
    Posts
    34

    Re: VBA - Match formulae to enter data on a pre-existing row using a form entry

    Hi BSB

    I really do appreciate your help

    The contents of ListBox2 ideally should go into one cell in one column (I'm not fussed which at this point). The cell will contain multiple items rather than a specific items and or source

    Thanks
    Michael

  15. #15
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,468

    Re: VBA - Match formulae to enter data on a pre-existing row using a form entry

    OK, I've amended the attached to include a multi entry ListBox. The code will loop through the list and if one or more entries are selected it will concatenate them into a string and paste that string into a cell on the relevant row.

    Any use?

    BSB
    Attached Files Attached Files

  16. #16
    Registered User
    Join Date
    03-16-2016
    Location
    London
    MS-Off Ver
    2013
    Posts
    34

    Re: VBA - Match formulae to enter data on a pre-existing row using a form entry

    Hey there

    Is there no challenge you can't fix?

    I've re-loaded the Macro with all the details and it now seems to be struggling with the piece of code ".Cells(UpdateRow, 27) = Left(ListStr, Len(ListStr) - 2)" Any ideas? I'm usually a bot more switched on, however the below is truly something that I need to master.


    PHP Code: 
    [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] 
    Last edited by Mlanger575; 11-01-2016 at 09:35 AM.

  17. #17
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,468

    Re: VBA - Match formulae to enter data on a pre-existing row using a form entry

    First off you'll need to amend your post to include code tags around your VBA. It keeps things neat and The Moderators are sticklers for that.

    Secondly, what do you mean exactly by:
    Quote Originally Posted by Mlanger575 View Post
    now seems to be struggling with the piece of code ".Cells(UpdateRow, 27) = Left(ListStr, Len(ListStr) - 2)"
    Struggling in what way? Do you get an error message? Is it being pasted in the wrong place?

    BSB
    Last edited by BadlySpelledBuoy; 11-01-2016 at 03:44 PM.

  18. #18
    Registered User
    Join Date
    03-16-2016
    Location
    London
    MS-Off Ver
    2013
    Posts
    34

    Re: VBA - Match formulae to enter data on a pre-existing row using a form entry

    Thanks BSB

    Amended.

    The Macro stalls and halts at the
    Please Login or Register  to view this content.
    area. I'm really not too sure how to fix this. The macro does not finish and the entry does not post into the cell.

    Thanks
    Michael

+ 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: 3
    Last Post: 02-14-2014, 12:23 PM
  2. Replies: 3
    Last Post: 09-24-2013, 11:01 AM
  3. Replies: 2
    Last Post: 06-07-2013, 09:08 AM
  4. Use form submission to enter data both in the form and not in the form
    By tsamuels in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-05-2013, 10:06 PM
  5. Show look up results in user form and display warning if overwritting existing entry
    By yapjooleong in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-26-2010, 01:50 PM
  6. [SOLVED] User Form will not scroll to Match Entry First Letter?
    By KBrenner in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-20-2006, 07:10 PM
  7. How do I set up Data entry to match My Application Form
    By Mr. Ziggy in forum Excel General
    Replies: 11
    Last Post: 04-06-2006, 01:50 PM
  8. Data Entry Form (similar to default Excel Data>Form)
    By tonydm in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-11-2005, 02:59 PM

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