another example of how you can achieve CopyPaste
Sub test1() Dim S As Worksheet: Set S = Sheets("Summary") Dim T As Worksheet: Set T = Sheets("ForTracker") With T .[A1] = S.[C2] .[B1] = S.[C6] .[C1] = S.[C8] .[D1] = S.[C3] .[E1] = S.[H8] .[F1] = S.[H9] .[G1] = S.[C5] End With End Sub
using an array
Sub test2() Dim S As Worksheet: Set S = Sheets("Summary") Dim T As Worksheet: Set T = Sheets("ForTracker") Dim CopyPaste, x% x = 0 With S CopyPaste = Array(.[C2], .[C6], .[C8], .[C3], .[H8], .[H9], .[C5]) End With For Each oCell In T.[A1:G1] oCell.Value = CopyPaste(x): x = x + 1 Next End Sub
using split line
Sub test3() Dim S As Worksheet: Set S = Sheets("Summary") Dim T As Worksheet: Set T = Sheets("ForTracker") Dim CopyPaste$ With S CopyPaste = .[C2] & "|" & .[C6] & "|" & .[C8] & "|" & .[C3] & "|" & .[H8] & "|" & .[H9] & "|" & .[C5] End With T.[A1:G1] = Split(CopyPaste, "|") End Sub
dictionary option
Sub test4() Dim S As Worksheet: Set S = Sheets("Summary") Dim T As Worksheet: Set T = Sheets("ForTracker") Dim CopyPaste As Object: Set CopyPaste = CreateObject("Scripting.Dictionary") Dim oCell As Range, Key As Variant, x% x = 1 For Each oCell In S.[C2,C6,C8,C3,H8,H9,C5] CopyPaste.Add x, oCell.Value: x = x + 1 Next x = 0 For Each Key In CopyPaste T.[A1].Offset(, x).Value = CopyPaste(Key) x = x + 1 Next End Sub
source share