Adjusting Copy Formula to multiple columns

JDeMaro22
2StarLounger
Posts: 120
Joined: 16 Oct 2021, 16:22

Adjusting Copy Formula to multiple columns

Post by JDeMaro22 »

Hello Hans,

I'm trying to adjust your formula from yesterday to copy multiple columns worth of data over to a new sheet instead of just one. I'm trying to copy all of the data in columns C1:AH1 from worksheet "Total US Report" and paste into C1 in "Loader" worksheet. I think my mistake is coming from the c1:ah range.

Sub CopyOver_LocationIDs()
With Sheets("Total US Report")
.Range(.Range("C1"), .Range("C1:AH" & .Rows.Count).End(xlUp)).Copy Destination:=Sheets("Loader").Range("C1")
End With
End Sub

Thanks,

Joshua

User avatar
HansV
Administrator
Posts: 80042
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Adjusting Copy Formula to multiple columns

Post by HansV »

How about

Code: Select all

Sub CopyOver_LocationIDs()
    With Sheets("Total US Report")
        .Range(.Range("C1"), .Range("AH" & .Rows.Count).End(xlUp)).Copy Destination:=Sheets("Loader").Range("C1")
    End With
End Sub
Best wishes,
Hans

snb
5StarLounger
Posts: 670
Joined: 14 Nov 2012, 16:06

Re: Adjusting Copy Formula to multiple columns

Post by snb »

Code: Select all

Sub M_snb()
  Sheets(Array("Total US Report", "Loader")).FillAcrossSheets Sheets("Total Us Report").Cells(1).CurrentRegion.Offset(, 2)
End Sub