Forum Discussion

Laura_Temmerman's avatar
Laura_Temmerman
Copper Contributor
Mar 23, 2022

Automatic adjustment in two working sheets

I have copied the table of my worksheet 1 into a second worksheet. Now I would like to know how it is possible that, when I modify worksheet 1, that modification is automatically carried through to worksheet 2.

As I keep my stock in excel, I would have to adjust each tab each time something changes. While the stock list is the same in both worksheets.

1 Reply

  • NikolinoDE's avatar
    NikolinoDE
    Platinum Contributor

    Laura_Temmerman 

    In Microsoft Excel, you can create a macro that is called only when a value is entered into a cell in a particular sheet or in any sheet that is currently open.

    How to run a macro when certain cells change in Excel

    In this upper link, Microsoft provides programming examples for illustration only, without warranty either expressed or implied.

     

    or with this Macro...

    OptionExplicit
    Private Sub Worksheet_Change(ByVal Target As Excel.Range)
    Dim Range As Range, MSG As Integer, Target As Range, Isec
    If Target.Cells.Count > 1 Then exit Sub
    Set Range = Sheets("Sheet2").[A1:Z100]
    Set Target = Target
    Set Isec = Application.Intersect(Target, Range("A1:Z100"))
    If Not Isec Is Nothing Then
    If WorksheetFunction.Count(Range) > 0 Then
    MSG = MsgBox("Shall I now?")
    If MSG = vbNo Then Exit Sub
    MsgBox "Update Sheet2!"
    End If
    Set Target = Nothing
    Set Area = Nothing
    Set Isec = Nothing
    End If
    end sub

    Hope I could help you with these information & link.

     

    NikolinoDE

    I know I don't know anything (Socrates)

Resources