+ Reply to Thread
Results 1 to 11 of 11

Update userform

  1. #1
    Registered User
    Join Date
    08-04-2014
    Location
    Clarion, PA USA
    MS-Off Ver
    2013
    Posts
    20

    Update userform

    userform.jpg

    So, I've created a userform to add products to our product spreadsheet. I am using the following code to update the spreadsheet but I am getting a compile error: For without Next

    Private Sub CMDupdate_Click()

    Dim SLNO As String
    SLNO = Trim(TXTSLNO.Text)
    lastrow = Worksheets("apparel").Cells(Row.Count, 1).End(xlUp).Row
    For i = 2 To lastrow
    If Worksheets("apparel").Cells(i, 1).Value = SLNO Then
    Worksheets("apparel").cels(i, 1).Value = Txtproduct.Text
    Worksheets("apparel").Cells(i, 3).Value = TxtDesign.Text
    Worksheets("apparel").Cells(i, 5).Value = TxtFeatures.Text
    Worksheets("apparel").Cells(i, 7).Value = cmbkeyupdate.Text
    Worksheets("apparel").Cells(i, 8).Value = TxtUpdate.Text
    Worksheets("apparel").Cells(i, 10).Value = TxtContinued.Text
    Worksheets("apparel").Cells(i, 12).Value = CMBGender.Text
    Worksheets("apparel").Cells(i, 13).Value = TXTMenHTML.Text
    Worksheets("apparel").Cells(i, 14).Value = TxtWomenHTML.Text
    Worksheets("apparel").Cells(i, 15).Value = CMBType.Text
    Worksheets("apparel").Cells(i, 16).Value = CMBSeason.Text
    Worksheets("apparel").Cells(i, 17).Value = TxtYear.Text
    End If

    End Sub

    Any thoughts?

  2. #2
    Valued Forum Contributor MikeVol's Avatar
    Join Date
    12-30-2020
    Location
    Odessa / Ukraine
    MS-Off Ver
    MSO Prof Plus 2021 x64 (En)
    Posts
    502

    Re: Update userform

    Hi. Before the row with End If insert one more row then write Next i. Like that:
    Please Login or Register  to view this content.

  3. #3
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,700

    Re: Update userform

    explain where you want the data to go.
    If you use a loop like you suggest with your "For i = 2 to LastRow", you need "Next i" between End If and End Sub.
    Do you need the data entered in rows 2 to 14 and columns A to Q? (2 To LastRow and 13 entries might not jive either)

    I suggest you explain in detail where everything needs to go
    The inherent weakness of the liberal society: a too rosy view of humanity.

  4. #4
    Registered User
    Join Date
    08-04-2014
    Location
    Clarion, PA USA
    MS-Off Ver
    2013
    Posts
    20

    Re: Update userform

    All of it goes in the "Apparel" sheet

    Txtproduct.Text goes to Column B
    TxtDesign.Text --- Colum C
    TxtFeatures.Text--- E
    cmbkeyupdate.Text-----G
    TxtUpdate.Text---H
    TxtContinued.Text---J
    CMBGender.Text --- L
    TXTMenHTML.Text --- M
    TxtWomenHTML.Text ---N
    CMBType.Text---o
    CMBSeason.Text----p
    TxtYear.Text----Q

  5. #5
    Valued Forum Contributor MikeVol's Avatar
    Join Date
    12-30-2020
    Location
    Odessa / Ukraine
    MS-Off Ver
    MSO Prof Plus 2021 x64 (En)
    Posts
    502

    Re: Update userform

    Hi! Try it:
    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    08-04-2014
    Location
    Clarion, PA USA
    MS-Off Ver
    2013
    Posts
    20

    Re: Update userform

    Thank you. That's helpful. As you can imagine, I'm not great at VBA. The code you did makes sense. It's still not allowing for the rows to be updated. I'm wondering if some of the VBA I've used to add the other CMD buttons is interfering. or perhaps some I did in the initializing?

  7. #7
    Valued Forum Contributor MikeVol's Avatar
    Join Date
    12-30-2020
    Location
    Odessa / Ukraine
    MS-Off Ver
    MSO Prof Plus 2021 x64 (En)
    Posts
    502

    Re: Update userform

    Attach your sample file in order to see and understand the essence of your problem. Perhaps you have some other macros in the book, we do not see it. We are waiting for an example file from you to resolve your issue as soon as possible.
    MikeVol.

  8. #8
    Registered User
    Join Date
    08-04-2014
    Location
    Clarion, PA USA
    MS-Off Ver
    2013
    Posts
    20

    Re: Update userform

    I've taken out all of the data, but the VBA and tabs should all still be there

  9. #9
    Valued Forum Contributor MikeVol's Avatar
    Join Date
    12-30-2020
    Location
    Odessa / Ukraine
    MS-Off Ver
    MSO Prof Plus 2021 x64 (En)
    Posts
    502

    Re: Update userform

    Hi! Try it.
    Made some changes to your file, have a look.
    Attached Files Attached Files

  10. #10
    Registered User
    Join Date
    08-04-2014
    Location
    Clarion, PA USA
    MS-Off Ver
    2013
    Posts
    20

    Re: Update userform

    that's perfect! Thank you

  11. #11
    Valued Forum Contributor MikeVol's Avatar
    Join Date
    12-30-2020
    Location
    Odessa / Ukraine
    MS-Off Ver
    MSO Prof Plus 2021 x64 (En)
    Posts
    502

    Re: Update userform

    Quote Originally Posted by shaun.burke View Post
    Thank you
    Please! If your issue is resolved then you can close this thread.

+ 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. [SOLVED] Need to update database with Update button on userform
    By asoler in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 09-03-2015, 08:13 PM
  2. How to Update userform : listbox1 update automatically
    By HaroonSid in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-05-2014, 11:28 AM
  3. update value and edit items already update on sheet by userform
    By tjxc32m in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 11-08-2013, 10:13 AM
  4. Update excel based on userform text box update
    By sivakumar123 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-11-2013, 01:01 AM
  5. [SOLVED] update button on userform does not update all cells in worksheet
    By tutke in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 09-27-2012, 03:07 AM
  6. Update records via UserForm
    By john55 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-26-2011, 04:04 PM
  7. how to update a userform after every use
    By jsmity in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-10-2008, 11:31 AM

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