CESBoston
CESBoston

Reputation: 83

Copy only selected range of the row

I am trying to replace "EntireRow.Copy" to only copy the range of columns F:AB.

Currently my code: xRg(K).EntireRow.CopyDestination:=

Copies the whole row. How can I have it select only the desired range?

Upvotes: 1

Views: 110

Answers (3)

SJR
SJR

Reputation: 23081

Assuming xRg is a range (please post more code)

Range(Cells(xRg(K).Row, "F"), Cells(xRg(K).Row, "AB")).Copy

Upvotes: 1

Error 1004
Error 1004

Reputation: 8230

Using the below you copy from row 1 to row 10 of columns F:AB

Option Explicit

Sub test()

    With ThisWorkbook.Worksheets("Sheet1")
        .Range(.Cells(1, "F"), .Cells(10, "AB")).Copy
    End With

End Sub

Upvotes: 0

JR87
JR87

Reputation: 95

I do this with a delete function I have:

sht.Range(col1 & ":" & col2).delete

You could modify it to do this:

ThisWorkbook.Sheets("Sheet2").Range("A1:C1").Value=ThisWorkbook.Sheets("Sheet1").Range("A1:C1").Value

You'd obviously need to swap out A1:C1 with variables based on some criteria. But that will set a range of cells equal to another range

Upvotes: 1

Related Questions