LibbyB
LibbyB

Reputation: 81

vba swapping two row ranges

I am trying to swap two rows with vba.

I have this code:

Sub copyrow()
    Dim temp1 As Range, temp2 As Range, x As Variant
    Set temp1 = Range("F4:U4")
    Set temp2 = Range("F6:U6")

    x = temp1
    temp1 = temp2
    temp2 = x
End Sub

temp2 gets filled with temp1 which is correct, but somehow temp1 ends up empty? Not sure where I've gone wrong

Upvotes: 0

Views: 92

Answers (1)

BigBen
BigBen

Reputation: 49998

Specify the .Value:

x = temp1.Value
temp1.Value = temp2.Value
temp2.Value = x

Upvotes: 1

Related Questions