Home » excel » excel – Copy only selected range of the row

excel – Copy only selected range of the row

Posted by: admin May 14, 2020 Leave a comment

Questions:

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?

How to&Answers:

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

Answer:

Assuming xRg is a range (please post more code)

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

Answer:

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