+ Reply to Thread
Results 1 to 10 of 10

insert changes in the sheet

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    08-27-2019
    Location
    europa
    MS-Off Ver
    excel 2007
    Posts
    546

    insert changes in the sheet

    Hello,
    I hope to explain myself well
    is possible in the attached file this modification?

    Now at each change, inserting numbers, in columns F / G column E is updated

    If column F is modified, in column L is inserted "prelevato"
    If column G is modified, in column L is inserted "inserito"

    I ask for a change:

    each time the column F / G columns are changed, the sheet "modifiche" must be displayed



    articolo / descrizione / U.M. / fornitore / data / if "prelevato" or if "inserito" / q.tà / username

    for each change made in progressive sequence
    I hope I explained myself
    fc
    Attached Files Attached Files
    Last edited by xam99; 02-04-2020 at 05:21 PM.

  2. #2
    Valued Forum Contributor
    Join Date
    07-14-2017
    Location
    Poland
    MS-Off Ver
    Office 2010
    Posts
    536

    Re: insert changes in the sheet

    In the code I marked my code modification as '=== My code correction ==='.
    Private Sub Worksheet_Change(ByVal Target As Range)
        'per articoli disponibili
        
        
        Dim a()
        Dim MyText As String
                                          
           ActiveSheet.Unprotect "123456"
        
        'If Not Intersect(Target, Range("E:F")) Is Nothing Then
        If Not Intersect(Target, Range("F6:G" & Rows.Count)) Is Nothing Then
        
            If Target.Column = 6 Then
                MyText = "prelevato"
            Else
                MyText = "inserito"
            End If
            
            Application.EnableEvents = False
            Range("L" & Target.Row) = MyText
            Application.EnableEvents = True
            
    '        ============ My code correction =====================
            a = Range("A" & Target.Row & ":L" & Target.Row).Value
            With Sheets("modifiche")
                With .Range("A" & .Cells(Rows.Count, "A").End(3).Row)(2)
                    .Resize(1, 7) = Application.Index(a, 0, Array(1, 2, 3, 4, 11, 12, 10))
                    .Offset(0, 4) = CDate(Left(a(1, 11), 10))
                End With
            End With
    '       ==============================================
       Application.EnableEvents = False
       
        'ActiveSheet.Unprotect "123456"
           
     '------------------------------------------------------------------------
        If Not Intersect(Target, Range("A5:A1000,F5:G1000")) Is Nothing Then
             
            If Target.Column = 6 Then
                     
                If Cells(Target.Row, 5) = 0 Then
                    MsgBox "ATTENZIONE!: il disponibile č 0", vbExclamation + vbOKOnly, "AVVISO!"
                     Target = 0
                   GoTo Fine
                End If
                
                If Target.Value > Cells(Target.Row, 5) Then
                     MsgBox "ATTENZIONE!: la q.tŕ inserita č superiore alla q.tŕ disponibile", vbExclamation + vbOKOnly, "AVVISO!"
                    Target = 0
                    GoTo Fine
                End If
                                       
                Cells(Target.Row, 8) = Cells(Target.Row, 8) + Target.Value
            End If
           
            If Target.Column = 7 Then
                Cells(Target.Row, 9) = Cells(Target.Row, 9) + Target.Value
            End If
            Cells(Target.Row, 5) = Cells(Target.Row, 9) - Cells(Target.Row, 8)
                        
        If Cells(Target.Row, 2) = 0 Or Cells(Target.Row, 2) > 0 Or Cells(Target.Row, 2) <> "" Then '<<< mod. by wally and maxma62
                 'If Cells(Target.Row, 2) = 0 Or Cells(Target.Row, 2) > 0 Then
                 
                 On Error Resume Next
       
        '-----------------------------------------------------------------
        'Cells(Target.Row, 11).Select
        Cells(Target.Row, 11) = Format(Now, "dd-mm-yyyy  hh.mm.ss")
             'Cells(Target.Row, 10) = Application.UserName
        Cells(Target.Row, 10) = Environ("UserName")
               'Application.EnableEvents = True
        '----------------------------------------------------------------
        Resume
    End If
      '---------------------------
    Fine:
          '  Target = 0
      '---------------------------
        
            ActiveSheet.Protect "123456"
        End If
       Application.EnableEvents = True
       End If
    End Sub
    Attached Files Attached Files
    Best Regards,
    Maras.

  3. #3
    Forum Contributor
    Join Date
    08-27-2019
    Location
    europa
    MS-Off Ver
    excel 2007
    Posts
    546

    Re: insert changes in the sheet

    Hi maras_mak it is almost correct
    A change:
    add the modified quantity
    username must match Environ ("UserName")
    Attached Files Attached Files

  4. #4
    Valued Forum Contributor
    Join Date
    07-14-2017
    Location
    Poland
    MS-Off Ver
    Office 2010
    Posts
    536

    Re: insert changes in the sheet

    Change this part in the code.
    Does that give you the results you expect?
    '        ============ My code correction =====================
            a = Range("A" & Target.Row & ":L" & Target.Row).Value
            a(1, 11) = CDate(Left(a(1, 11), 10))
            a(1, 10) = Environ$("UserName")
            With Sheets("modifiche")
                With .Range("A" & .Cells(Rows.Count, "A").End(3).Row)(2)
                    .Resize(1, 7) = Application.Index(a, 0, Array(1, 2, 3, 4, 11, 12, 10))
                End With
            End With
    '       ==============================================

  5. #5
    Forum Contributor
    Join Date
    08-27-2019
    Location
    europa
    MS-Off Ver
    excel 2007
    Posts
    546

    Re: insert changes in the sheet

    Hi maras_mak it is almost correct
    '        ============ My code correction =====================
            a = Range("A" & Target.Row & ":L" & Target.Row).Value
            On Error Resume Next
            a(1, 11) = CDate(Left(a(1, 11), 10))
            a(1, 10) = Environ$("UserName")
            a(1, 11) = Format(Now, "dd-mm-yyyy  hh.mm.ss")
            With Sheets("modifiche")
                With .Range("A" & .Cells(Rows.Count, "A").End(3).Row)(2)
                    .Resize(1, 7) = Application.Index(a, 0, Array(1, 2, 3, 4, 11, 12, 10))
                End With
            End With
    '       ==============================================
    it must appear in the "quantità column of the "modifiche" sheet
    username it must appear in column G of the "modifiche" sheet
    the amount of the change made on column F or G.
    I entered on error resume next because if you edit a column with empty cells it gives an error
    xam
    Attached Files Attached Files

  6. #6
    Valued Forum Contributor
    Join Date
    07-14-2017
    Location
    Poland
    MS-Off Ver
    Office 2010
    Posts
    536

    Re: insert changes in the sheet

    Quote Originally Posted by xam99
    ...if you edit a column with empty cells it gives an error
    And what should be done?

  7. #7
    Forum Contributor
    Join Date
    08-27-2019
    Location
    europa
    MS-Off Ver
    excel 2007
    Posts
    546

    Re: insert changes in the sheet

    if modified the column F sheet "articoli" in sheet "modifiche" columng G the quantity must be displayed
    if modified the column G sheet "articoli" in sheet "modifiche" columng G the quantity must be displayed

  8. #8
    Valued Forum Contributor
    Join Date
    07-14-2017
    Location
    Poland
    MS-Off Ver
    Office 2010
    Posts
    536

    Re: insert changes in the sheet

    You could write what error appears because in my opinion this is not an error but information - look at the photo.
    That's how your code works. These are not my code fixes.
    Here is the corrected part of my code.
    '        ============ My code correction =====================
            a = Range("A" & Target.Row & ":L" & Target.Row).Value
            a(1, 10) = Environ$("UserName")
            If Target.Value > 0 Then a(1, 5) = Format(Now, "dd-mm-yyyy  hh.mm.ss")
            With Sheets("modifiche")
                    With .Range("A" & .[A1].CurrentRegion.Rows.Count + 1)
                        .Resize(1, 7) = Application.Index(a, 0, Array(1, 2, 3, 4, 5, 12, 10))
                    End With
            End With
    '       ==============================================
    Attached Images Attached Images

  9. #9
    Forum Contributor
    Join Date
    08-27-2019
    Location
    europa
    MS-Off Ver
    excel 2007
    Posts
    546

    Re: insert changes in the sheet

    Maybe I mean badly missing this

    if modified the column F sheet "articoli" in sheet "modifiche" columng G the quantity must be displayed
    if modified the column G sheet "articoli" in sheet "modifiche" columng G the quantity must be displayed

  10. #10
    Valued Forum Contributor
    Join Date
    07-14-2017
    Location
    Poland
    MS-Off Ver
    Office 2010
    Posts
    536

    Re: insert changes in the sheet

    Show solution - manually enter sample results in the "modifiche" worksheet when modifying columns F and G of the "articoli" worksheet.

+ 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. Macro insert multiple sheet and insert age band based on numbers
    By saravanan1981 in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 08-01-2017, 01:47 PM
  2. Replies: 4
    Last Post: 07-18-2017, 12:08 PM
  3. Replies: 4
    Last Post: 02-03-2015, 07:54 PM
  4. [SOLVED] VBA codes to insert the rows and copy the first entire row text and insert sheet
    By PRADEEPB270 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-26-2013, 05:05 AM
  5. Replies: 1
    Last Post: 11-20-2012, 10:01 PM
  6. Copy Sheet / Create & Name New Sheet / Insert Before a Sheet / Paste Data
    By thinkspac in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-12-2012, 02:27 PM
  7. Populate summary sheet (insert & index rows from info in columns on another sheet)
    By DerbysGal in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-03-2011, 01:54 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