+ Reply to Thread
Results 1 to 8 of 8

Userform problem adding to existing rows of data

  1. #1
    Registered User
    Join Date
    10-10-2007
    Posts
    22

    Userform problem adding to existing rows of data

    Hello Everyone,
    I have a scheduling program with two userforms. One form adds five different pieces of data to Cells A to E on a row in a worksheet. This worksheet has many existing rows of data, each row as an unique set of info(There no duplicate entries of Date(Cell A) and Simulator session(Cell C), I have code to prevent this). This form works 100%.
    Here is my trouble spot: The second form is for the schedulers to place names of Operators in these existing rows of data (cells H to J is where I want the data to go), What I want the second form to do is search an the existing rows on the worksheet, find a match based on two criteria; (Cell A)Date and (Cell C)Simulator Session. Then add the names of the operator(s) in the assigned columns in that same row.
    Something to this effect:
    If Userform(TxtDate) matches Cell A and UserForm(TxtSim) matches Cell C then add (Userform)TxtPilot to Cell 8 and userform(TxtNavs) to Cell 10 etc.

    Here is the code I started but can’t get to work, When I click the submit add button the form runs and clears itself like I want but I can’t get the data to go where it should

    Please Login or Register  to view this content.
    Any help would be greatly appreciated.
    Glenness

  2. #2
    Valued Forum Contributor
    Join Date
    04-11-2006
    Posts
    407
    At first glance there are a couple things I noted.
    1. That you use iRow yet you never give the variable a value.
    2. I'm not familiar with the use of cells(iRow, 1, 3)
    3. You never assign row_count a value either...

    To solve these I:
    1. Changed "i" to "iRow"
    2. took out cells(iRow, 1, 3) and made it cells(iRow, 1) and cells(iRow, 3)
    3. try something like row_count = ws.range("A" & rows.count).end(xlup).row

    See code below. Hope this solves the issue.
    Please Login or Register  to view this content.
    Last edited by Ikaabod; 10-18-2007 at 08:16 PM.

  3. #3
    Registered User
    Join Date
    10-10-2007
    Posts
    22
    Hi Ikaabod,
    First thank you for picking up my left over code from another issue, however the new code still will not add the data to the cell in the existing rows. On click the form pops up I input the data that I want to add hit submit, the form clears but nothing in the cells on the worksheet. I'm still scratching my head on this one.
    Glenness

    Attached is a sample of the file, I hope I attached this correctly...I apologize to all if I didn't.
    [attach]sched oper sample.zip[/attach]
    Attached Files Attached Files
    Last edited by glenness; 10-18-2007 at 09:05 PM. Reason: Forgot to attach sample file

  4. #4
    Valued Forum Contributor
    Join Date
    04-11-2006
    Posts
    407
    Revisions are noted in code.
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    10-10-2007
    Posts
    22
    Hello Ikaabod,
    Thanks again for responding, I thought this would be an easy one, however I still can't get this to work, your code runs but it still will not place the data in the applicable cells. I have attached the sample with your new code attached.
    Glenness
    Attached Files Attached Files
    Last edited by glenness; 10-20-2007 at 08:45 AM.

  6. #6
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Youv'e placed the code in the Worksheet code module, not the UserForm.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  7. #7
    Registered User
    Join Date
    10-10-2007
    Posts
    22
    Hi RoyUK,
    You were correct, I did place the code in the Worksheet code module( I pasted it there by accident and for to delete it) however the code was in the userform module as well. However when I removed the code from the Worksheet code module and left it in the Userform module it still does not run. I'm at a lost with this one! Attached is the sample with the code removed from the Worksheet module. Any help appreciated.
    Glenness
    Attached Files Attached Files

  8. #8
    Registered User
    Join Date
    10-10-2007
    Posts
    22

    Solved!

    Thank You Ikaabod and RoyUK for all your help,
    For some strange reason the code was not initially running, however when I went back to it tonight it worked as advertised! Thanks again for for help and patients with us Noobs!
    Glenness

+ 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