Copy and Paste Special with VBA

0

I have a VBA script that copies a column (from an Excel spreadsheet) with formulas and glues only the result (Paste Special).

But I would like to automate this task, for example:
Whenever you add some information in the "A" column, the data in column "B" is automatically updated.

Here is an example of the code:

Public Sub pasteVal()
   Range("A1:A10").Select
   Selection.Copy
   Range("B1:B10").Select
   Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _:=False, Transpose:=False
End Sub
    
asked by anonymous 27.12.2018 / 14:30

1 answer

0

Miguel,

Just one example:

Private Sub Worksheet_Change(ByVal Target As Range)
    Dim KeyCells As Range

    ' The variable KeyCells contains the cells that will
    ' cause an alert when they are changed.
    Set KeyCells = Range("A1:C10")

    If Not Application.Intersect(KeyCells, Range(Target.Address)) _
           Is Nothing Then

        ' Display a message when one of the designated cells has been 
        ' changed.
        ' Place your code here.
        MsgBox "Cell " & Target.Address & " has changed."

    End If

End Sub

When a cell changes in Excel, it fires this sub.

See more at:

How to run a macro when some cells are changed in Excel

    
27.12.2018 / 17:39