+ Reply to Thread
Results 1 to 13 of 13

update value and edit items already update on sheet by userform

Hybrid View

tjxc32m update value and edit items... 11-05-2013, 04:05 AM
tjxc32m Re: update value and edit... 11-06-2013, 12:44 AM
kvsrinivasamurthy Re: update value and edit... 11-06-2013, 03:38 AM
tjxc32m Re: update value and edit... 11-06-2013, 09:52 AM
jaslake Re: update value and edit... 11-06-2013, 12:27 PM
tjxc32m Re: update value and edit... 11-06-2013, 02:15 PM
jaslake Re: update value and edit... 11-06-2013, 02:22 PM
jaslake Re: update value and edit... 11-06-2013, 10:56 AM
tjxc32m Re: update value and edit... 11-06-2013, 02:09 PM
tjxc32m Re: update value and edit... 11-07-2013, 01:41 AM
jaslake Re: update value and edit... 11-07-2013, 11:39 AM
tjxc32m Re: update value and edit... 11-08-2013, 01:48 AM
jaslake Re: update value and edit... 11-08-2013, 10:13 AM
  1. #1
    Registered User
    Join Date
    10-04-2013
    Location
    Bangalore
    MS-Off Ver
    Excel 2007
    Posts
    12

    Re: update value and edit items already update on sheet by userform

    Sorry about that. The password for ther Item master list is "edolpsgge", and the other sheets its "godspeed". :-)

    Thanks,
    Jolly

  2. #2
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: update value and edit items already update on sheet by userform

    Hi tjxc32m

    In the attached this Code is in ThisWorkbook Module and runs each time the Workbook is opened. It protects each Worksheet with the appropriate Password; the Protection applied allows Macros to run on Protected Worksheets.
    Private Sub Workbook_Open()
        Dim PW As String, PW1 As String
        Dim wSht As Worksheet
    
        PW = "godspeed"
        PW1 = "edolpsgge"
        For Each wSht In ActiveWorkbook.Sheets
            If wSht.Name = "ITEMS MASTER LIST" Then
                'set protection using UserInterface to allow macros to work
                With wSht
                    .Protect _
                            Password:=PW1, _
                            DrawingObjects:=True, _
                            Contents:=True, _
                            Scenarios:=True, _
                            UserInterfaceOnly:=True
                    wSht.EnableSelection = xlUnlockedCells
                End With
            Else
                With wSht
                    .Protect _
                            Password:=PW, _
                            DrawingObjects:=True, _
                            Contents:=True, _
                            Scenarios:=True, _
                            UserInterfaceOnly:=True
                    wSht.EnableSelection = xlUnlockedCells
                End With
            End If
        Next wSht
    End Sub
    This Code is in "ITEM MASTER LIST" Code Module and allows changes made to "ITEM MASTER LIST" to be populated to all other Worksheets (without unprotecting the other Worksheets). You WILL need to unprotect "ITEM MASTER LIST" to make changes and then protect it after your changes are made.

    You COULD unlock the Cells you wish to change but then they would be available to anyone with access to "ITEM MASTER LIST".
    Option Explicit
    Private Sub Worksheet_Change(ByVal Target As Range)
        Dim ws As Worksheet
        Dim rng As Range, cel As Range
    
        If Not Target.Column = 5 Then Exit Sub
        Application.ScreenUpdating = False
        Application.EnableEvents = False
        For Each ws In ThisWorkbook.Sheets
            If ws.Name <> "ITEMS MASTER LIST" Then
                With ws
                    Set rng = .Columns(3)
                    Set cel = rng.Find(Target.Offset(0, -3).Value, , xlValues, xlWhole, xlByRows, xlNext, False)
                    If Not cel Is Nothing Then
                        cel.Offset(0, 3).Value = Target.Offset(0, 1).Value
                        cel.Offset(0, 4).Value = cel.Offset(0, 1).Value * cel.Offset(0, 3).Value
                    End If
                End With
            End If
        Next ws
        Application.ScreenUpdating = True
        Application.EnableEvents = True
    End Sub
    This Code (revised from your original Code) is in the UserForm and is attached to the Submit Button
    Private Sub btnsubmit_Click()
        Dim rowcount As Long
        Dim c As Range, rng As Range
        If Me.Cbitem.Text = "" Then
            MsgBox " Please Enter Ingredient "
            Me.Cbitem.SetFocus
        End If
        'range above item
        If Not IsNumeric(Me.tbqty.Value) Then
            MsgBox " Quantity to be Numeric Value "
            Me.tbqty.SetFocus
        End If
        'range above quantity
        If Me.Cbunit.Text = "" Then
            MsgBox " Unit to be Metrics "
            Me.Cbunit.SetFocus
        End If
        'range about unit
        If Not IsNumeric(Me.cbprice.Value) Then
            MsgBox " Price to be Numeric Value "
            Me.cbprice.SetFocus
        End If
        'range for price
        If Me.cbprice.Value = 0 Then
            MsgBox " NO PRICE ASSIGNED "
            Me.cbprice.SetFocus
        End If
        'range for no price input
    
        With ActiveSheet
            Set rng = .Range(("C6"), .Range("C6").End(xlDown))
    
            Set c = rng.Find(Me.Cbitem.Value, LookIn:=xlValues)
            If Not c Is Nothing Then
                '            Me.btnundo.Enabled = False
                .Cells(c.Row, 3) = Cbitem.Text
                .Cells(c.Row, 4) = tbqty.Value
                .Cells(c.Row, 5) = Cbunit.Text
                .Cells(c.Row, 6) = cbprice.Value
                .Cells(c.Row, 7) = tbcost.Value
                '            Me.btnundo.Enabled = False
            Else
                '            Me.btnundo.Enabled = True
                erow = ActiveSheet.Cells(Rows.Count, 3).End(xlUp).Offset(1, 0).Row
    
                .Cells(erow, 3) = Cbitem.Text
                .Cells(erow, 4) = tbqty.Value
                .Cells(erow, 5) = Cbunit.Text
                .Cells(erow, 6) = cbprice.Value
                .Cells(erow, 7) = tbcost.Value
    
            End If
            Flag = True
            Cbitem.ListIndex = -1
            tbqty.Value = ""
            Cbunit.Value = ""
            cbprice.Value = ""
            tbcost.Value = ""
            Flag = False
        End With
    End Sub
    Attached Files Attached Files
    John

    If you have issues with Code I've provided, I appreciate your feedback.

    In the event Code provided resolves your issue, please mark your Thread as SOLVED.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

+ 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] VBA Userform Edit/Update record help
    By sa.1985 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-20-2013, 10:29 AM
  2. 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
  3. [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
  4. edit data in userform and update spreadsheet
    By nunans in forum Excel General
    Replies: 2
    Last Post: 03-08-2012, 04:44 AM
  5. Edit/Update list from userform (auto alphabetized)
    By Jogier505 in forum Excel Programming / VBA / Macros
    Replies: 16
    Last Post: 12-07-2009, 06:28 PM

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