VBA How to copy the content of a cell without .Select VBA How to copy the content of a cell without .Select vba vba

VBA How to copy the content of a cell without .Select


Worksheets("Get Address").Range("A33").Copy _       Destination := Worksheets("Label").Range("A1")


to copy and paste values only then use following

Worksheets("Label").Range("A1").value = _   Worksheets("Get Address").Range("A33").value

this statement will not use clip board


You can loop thru each cell of the range to copy and set each cell's value, comment, etc in the target destination.Here's an example.

Sub CopySpecial(p_RangeFrom As String, p_OffsetRow As Integer, p_OffsetColumn As Integer)    Dim l_Row As Integer    Dim l_Column As Integer    Dim thisCell As Range    Dim l_TargetCell As Range    l_Row = Range(p_RangeFrom).Row    l_Column = Range(p_RangeFrom).Column    For Each thisCell In Range(p_RangeFrom)        Set l_TargetCell = Range(Cells(thisCell.Row + p_OffsetRow, thisCell.Column + p_OffsetColumn).Address)        ' Copy the text        l_TargetCell.Value = thisCell.Value        ' Copy the comment only if we have a comment to copy        If Not thisCell.Comment Is Nothing Then            ' Delete any existing comment in the target cell, if any.            ' If you don't to this the .AddComment Method below will fail.            If Not l_TargetCell.Comment Is Nothing Then l_TargetCell.Comment.Delete            Call l_TargetCell.AddComment(thisCell.Comment.Text)        End If        ' Add more items to copy here, such as color, etc.    NextEnd SubSub TestCall()    Call CopySpecial("A1:B2", 3, 3)End Sub