+ Reply to Thread
Results 1 to 5 of 5

Trying to get new inputs from Userform into New/Unused Columns

Hybrid View

  1. #1
    Registered User
    Join Date
    04-19-2017
    Location
    Toronto, Canada
    MS-Off Ver
    2016
    Posts
    4

    Trying to get new inputs from Userform into New/Unused Columns

    Hi All,

    I am trying to get values from a userform input into columns; every time I put a new value into a new userform, the results should shift over to the next column. The code in question is below.

    If Me.ComboBox1.Value = "" Then
            MsgBox "Select the part"
    Else
    Set Found = Sheets("PARTS_TRACKER").Range("A:A").Find(What:=Me.ComboBox1.Value, _
                                                           LookIn:=xlValues, _
                                                           LookAt:=xlWhole, _
                                                           SearchOrder:=xlByRows, _
                                                           SearchDirection:=xlNext, _
                                                           MatchCase:=False)
          
    Found.Offset(0, PR).Value = Me.TextBox43.Value
     
    End If
    Last edited by Leith Ross; 04-19-2017 at 08:38 PM. Reason: Added Code Tags

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Trying to get new inputs from Userform into New/Unused Columns

    Hello Don,

    Welcome to the forum!

    From your code it appears that the parts are in column "A" of the "Parts_Tracker" worksheet. Assuming you want to add a new part at the end of the column if it does not exist then this code should work for you.

        Dim Found   As Range
        Dim Rng     As Range
        
            ' Start with cell A2, in case A1 is header.
            Set Rng = Sheets("PARTS_TRACKER").Range("A2", Cells(Rows.Count, "A").End(xlUp))
            
            ' Look for the part in column "A".
            Set Found = Rng.Find(Me.ComboBox1.Value, , xlValues, xlWhole, xlByRows, xlNext, False, False, False)
            
            ' Add the value if it is missing to the next empty row below the range.
            If Found Is Nothing Then
                Rng.Cells(Rng.Rows.Count + 1, 1).Value = Me.ComoBox1.Value
            End If
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Registered User
    Join Date
    04-19-2017
    Location
    Toronto, Canada
    MS-Off Ver
    2016
    Posts
    4

    Re: Trying to get new inputs from Userform into New/Unused Columns

    Hi Leith,

    Thanks for replying! I think that we might have gotten our signals crossed however; essentially, the userform in question is using a combobox to select a part, input a quantity in a text box beside it and is using the found.offset command to input the correct quantity beside the correct part. However, while I am managing to get the number to find the correct cell, everytime there is a new entry it will only overwrite in the same cell (First entry into B2, second entry goes into B2 instead of C2)

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Trying to get new inputs from Userform into New/Unused Columns

    Hello Don,

    This will place the quantity in the next empty cell to the right of the part number on the same row.

            If Me.ComboBox1.Value = "" Then
                MsgBox "Select the part"
            Else
                Set Found = Sheets("PARTS_TRACKER").Range("A:A").Find(What:=Me.ComboBox1.Value, _
                                                           LookIn:=xlValues, _
                                                           LookAt:=xlWhole, _
                                                           SearchOrder:=xlByRows, _
                                                           SearchDirection:=xlNext, _
                                                           MatchCase:=False)
                
                If Not Found Is Nothing Then
                    PR = Sheets("PARTS_TRACKER").Cells(Found.Row, Columns.Count).End(xlToLeft).Column + 1
                    Found.Offset(0, PR).Value = Me.TextBox43.Value
                End If
            End If

  5. #5
    Registered User
    Join Date
    04-19-2017
    Location
    Toronto, Canada
    MS-Off Ver
    2016
    Posts
    4

    Re: Trying to get new inputs from Userform into New/Unused Columns

    Hi Leith,

    Thank you so much! It works!

+ 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. How do you get rid of unused rows and columns?
    By tlong1962 in forum Excel General
    Replies: 2
    Last Post: 03-06-2013, 05:19 PM
  2. Making Unused UserForm Textboxes Invisible
    By ChemistB in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-05-2011, 01:00 PM
  3. How do I clear unused rows or columns
    By CheeseIsGood in forum Excel General
    Replies: 4
    Last Post: 05-11-2007, 06:14 PM
  4. removing unused columns and rows
    By WarrenC in forum Excel General
    Replies: 1
    Last Post: 07-10-2006, 04:34 PM
  5. Deleting unused columns
    By dramajuana in forum Excel General
    Replies: 2
    Last Post: 06-10-2006, 07:20 PM
  6. Help selecting a range in vba from userform inputs
    By grievesy in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-27-2006, 05:35 PM
  7. Eliminate unused columns
    By jlbreyer in forum Excel General
    Replies: 3
    Last Post: 06-20-2005, 03:05 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