Copy data from multiple sheets without formatting

sofas

Well-known Member
Joined
Sep 11, 2022
Messages
559
Office Version
  1. 2021
  2. 2019
Platform
  1. Windows
Hello.Use the following code to copy several separate columns from several sheets to one sheet.my problem is that it copies formats and colors how can I copy only values


VBA Code:
Sub Sheets_Arrays2()
Dim LR&, LR2&
Dim wsData        As Variant
Dim Dest    As Worksheet: Set Dest = Sheets("main")


For Each wsData In Sheets(Array("op2023", "mt10", "zt15"))
LR = wsData.Cells(Rows.Count, "E").End(xlUp).Row
LR2 = Dest.Cells(Rows.Count, "C").End(xlUp).Row

Application.ScreenUpdating = False

   wsData.Range("E10:F" & LR).Copy Destination:=Dest.Range("C" & LR2 + 1)
   wsData.Range("H10:H" & LR).Copy Destination:=Dest.Range("E" & LR2 + 1)
   wsData.Range("J10:J" & LR).Copy Destination:=Dest.Range("F" & LR2 + 1)
   wsData.Range("L10:M" & LR).Copy Destination:=Dest.Range("G" & LR2 + 1)
   wsData.Range("P10:Q" & LR).Copy Destination:=Dest.Range("I" & LR2 + 1)

  Application.ScreenUpdating = True

  Next wsData

End Sub
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
As an example

Rich (BB code):
wsData.Range("E10:F" & LR).Copy Destination:=Dest.Range("C" & LR2 + 1)
wsData.Range("E10:F" & LR).Copy
Dest.Range("C" & LR2 + 1).PasteSpecial xlPasteValues
 
Upvote 0
As an example

Rich (BB code):
wsData.Range("E10:F" & LR).Copy Destination:=Dest.Range("C" & LR2 + 1)
wsData.Range("E10:F" & LR).Copy
Dest.Range("C" & LR2 + 1).PasteSpecial xlPasteValues
Thank you. Can I find a faster code because the data volume is too large
 
Upvote 0
Thank you. Can I find a faster code because the data volume is too large
Kindly give a shot @sofas , based on column E:F , H , J , L:M, P:Q (starting row 10)

i run 10k code, it's taking roughly 5second

VBA Code:
Sub Sheets_Arrays2()
Dim LR&, LR2&
Dim wsData        As Variant
Dim Dest    As Worksheet: Set Dest = Sheets("main")
Dim a()

For Each wsData In Sheets(Array("op2023", "mt10", "zt15"))
LR = wsData.Cells(Rows.Count, "E").End(xlUp).Row
LR2 = Dest.Cells(Rows.Count, "C").End(xlUp).Row

Application.ScreenUpdating = False
 
    With wsData
 
        Dest.Range("c" & LR2 + 1 & ":d" & LR2 + LR - 9).Value = wsData.Range("E10:F" & LR).Value
        Dest.Range("e" & LR2 + 1 & ":e" & LR2 + LR - 9).Value = wsData.Range("H10:H" & LR).Value
        Dest.Range("f" & LR2 + 1 & ":F" & LR2 + LR - 9).Value = wsData.Range("J10:J" & LR).Value
        Dest.Range("g" & LR2 + 1 & ":h" & LR2 + LR - 9).Value = wsData.Range("L10:M" & LR).Value
        Dest.Range("i" & LR2 + 1 & ":j" & LR2 + LR - 9).Value = wsData.Range("P10:Q" & LR).Value
 
    End With
 

  Application.ScreenUpdating = True

  Next wsData

End Sub

op2o23:
Book1
EFGHIJKLMNOPQ
10e10 mt10f11h10j10l10m10p10q10
11e10 mt10f12h10j10l11m11p10q10
12e10 mt10f13h10j10l12m12p10q10
13e10 mt10f14h10j10l13m13p10q10
14e10 mt10f15h10j10l14m14p10q10
15e10 mt10f16h10j10l15m15p10q10
16e10 mt10f17h10j10l16m16p10q10
17e10 mt10f18h10j10l17m17p10q10
18e10 mt10f19h10j10l18m18p10q10
19e10 mt10f20h10j10l19m19p10q10
op2023


mt10
Book1
EFGHIJKLMNOPQ
10e10 mt10f11h10j10l10m10p10q10
11e10 mt10f12h10j10l11m11p10q10
12e10 mt10f13h10j10l12m12p10q10
13e10 mt10f14h10j10l13m13p10q10
14e10 mt10f15h10j10l14m14p10q10
15e10 mt10f16h10j10l15m15p10q10
16e10 mt10f17h10j10l16m16p10q10
17e10 mt10f18h10j10l17m17p10q10
mt10

zt15
Book1
EFGHIJKLMNOPQ
10e10 zt15f11h10j10l10m10p10q10
11e10 zt15f12h10j10l11m11p10q10
12e10 zt15f13h10j10l12m12p10q10
13e10 zt15f14h10j10l13m13p10q10
14SHEET3f15h10j10l14m14p10q10
zt15


main
1687939452249.png
 
Upvote 1
Solution
Kindly give a shot @sofas , based on column E:F , H , J , L:M, P:Q (starting row 10)

i run 10k code, it's taking roughly 5second

VBA Code:
Sub Sheets_Arrays2()
Dim LR&, LR2&
Dim wsData        As Variant
Dim Dest    As Worksheet: Set Dest = Sheets("main")
Dim a()

For Each wsData In Sheets(Array("op2023", "mt10", "zt15"))
LR = wsData.Cells(Rows.Count, "E").End(xlUp).Row
LR2 = Dest.Cells(Rows.Count, "C").End(xlUp).Row

Application.ScreenUpdating = False
 
    With wsData
 
        Dest.Range("c" & LR2 + 1 & ":d" & LR2 + LR - 9).Value = wsData.Range("E10:F" & LR).Value
        Dest.Range("e" & LR2 + 1 & ":e" & LR2 + LR - 9).Value = wsData.Range("H10:H" & LR).Value
        Dest.Range("f" & LR2 + 1 & ":F" & LR2 + LR - 9).Value = wsData.Range("J10:J" & LR).Value
        Dest.Range("g" & LR2 + 1 & ":h" & LR2 + LR - 9).Value = wsData.Range("L10:M" & LR).Value
        Dest.Range("i" & LR2 + 1 & ":j" & LR2 + LR - 9).Value = wsData.Range("P10:Q" & LR).Value
 
    End With
 

  Application.ScreenUpdating = True

  Next wsData

End Sub

op2o23:
Book1
EFGHIJKLMNOPQ
10e10 mt10f11h10j10l10m10p10q10
11e10 mt10f12h10j10l11m11p10q10
12e10 mt10f13h10j10l12m12p10q10
13e10 mt10f14h10j10l13m13p10q10
14e10 mt10f15h10j10l14m14p10q10
15e10 mt10f16h10j10l15m15p10q10
16e10 mt10f17h10j10l16m16p10q10
17e10 mt10f18h10j10l17m17p10q10
18e10 mt10f19h10j10l18m18p10q10
19e10 mt10f20h10j10l19m19p10q10
op2023


mt10
Book1
EFGHIJKLMNOPQ
10e10 mt10f11h10j10l10m10p10q10
11e10 mt10f12h10j10l11m11p10q10
12e10 mt10f13h10j10l12m12p10q10
13e10 mt10f14h10j10l13m13p10q10
14e10 mt10f15h10j10l14m14p10q10
15e10 mt10f16h10j10l15m15p10q10
16e10 mt10f17h10j10l16m16p10q10
17e10 mt10f18h10j10l17m17p10q10
mt10

zt15
Book1
EFGHIJKLMNOPQ
10e10 zt15f11h10j10l10m10p10q10
11e10 zt15f12h10j10l11m11p10q10
12e10 zt15f13h10j10l12m12p10q10
13e10 zt15f14h10j10l13m13p10q10
14SHEET3f15h10j10l14m14p10q10
zt15


main
View attachment 94356
Thank you very much, it works with high efficiency
 
Upvote 0

Forum statistics

Threads
1,223,888
Messages
6,175,212
Members
452,618
Latest member
Tam84

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top