VBA Code Help Needed to Copy Specific Columns Minus Headers in Source Sheet and Paste to Specific columns in Target Sheets. Please.

JPatty

New Member
Joined
Sep 21, 2022
Messages
14
Office Version
  1. 365
  2. 2019
  3. 2011
Platform
  1. Windows
I have a work book that has multiple sheets with columns that don't change, but the number of cells with data in each column does. So I would need to copy down to first blank cell in that column. Sheet1 is the source data, I need to copy everything from A2, D2, E2, and F2 down to the first blank cell and paste to Sheet2 starting in A2, F2, G2, and H2, then copy starting at A2, G2, H2, and I2 in Sheet1 down to first blank cell and paste in Sheet3 starting in A2, F2, G2, and H2, then copy starting at A2, J2, K2, and L2 in Sheet1 down to first blank cell and paste in Sheet4 starting in A2, F2, G2, and H2, and so on. Coping sets of data from Sheet1 pasting
in target sheet then moving down by 3 cells in Sheet1 to next target sheet, and so on.
 

Attachments

  • Sheet1.png
    Sheet1.png
    17.1 KB · Views: 11
  • Sheet2.png
    Sheet2.png
    7.4 KB · Views: 11
  • Sheet3.png
    Sheet3.png
    6.3 KB · Views: 14
  • Sheet4.png
    Sheet4.png
    7.5 KB · Views: 11
  • Sheet5.png
    Sheet5.png
    7.7 KB · Views: 13

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
It is hard to work with pictures. It would be easier to help if you could use the XL2BB add-in (icon in the menu) to attach a screenshot (not a picture) of Sheet1. Alternately, you could upload a copy of your file to a free site such as www.box.com or www.dropbox.com. Once you do that, mark it for 'Sharing' and you will be given a link to the file that you can post here. Explain in detail what you want to do referring to specific cells, rows, columns and sheets using a few examples from your data (de-sensitized if necessary).
 
Upvote 0
Located below are the Xl2bb mini sheets associated with the initial post.

Copy and Paste Different Coulmns to Different Worksheets.xlsx
ABCDEFGHIJKLMNOP
1StartEnd MoveCustomer CityCustomer StateCustomer ZipDestination1 CityDestination1 StateDestination1 ZipDestination2 CityDestination2 StateDestination2 ZipDestination3 CityDestination3 StateDestination3 Zip
21/1/20231/1/2023New YorkNew York12345Chicago Illinios12345MadisonWisconson12345Billings Montana12345
3Atlantic CityNew Jersey12345JacksonvilleFlorida12345Atlanta Georgia12345Dallas Texas12345
4
5
6
7
8
9
10
11
12
13
14
15
16
17
Sheet1


Copy and Paste Different Coulmns to Different Worksheets.xlsx
ABCDEFGHIJK
1Effective Not EffectiveServiceMatchZoneOrigin CityOrigin StateOrigin ZipTimeRate
2
3
4
5
6
7
Sheet2


Copy and Paste Different Coulmns to Different Worksheets.xlsx
ABCDEFGHIJK
1Effective Not EffectiveServiceMatchZoneOrigin CityOrigin StateOrigin ZipTimeRate
2
3
4
5
6
7
Sheet3


Copy and Paste Different Coulmns to Different Worksheets.xlsx
ABCDEFGHIJK
1Effective Not EffectiveServiceMatchZoneOrigin CityOrigin StateOrigin ZipTimeRate
2
3
4
5
6
7
Sheet4


Copy and Paste Different Coulmns to Different Worksheets.xlsx
ABCDEFGHIJK
1Effective Not EffectiveServiceMatchZoneOrigin CityOrigin StateOrigin ZipTimeRate
2
3
4
5
6
7
Sheet5
 
Upvote 0
Try:
VBA Code:
Sub CopyData()
    Application.ScreenUpdating = False
    Dim LastRow As Long, srcWS As Worksheet, x As Long, y As Long: y = 4
    Set srcWS = Sheets("Sheet1")
    LastRow = srcWS.Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
    For x = 2 To 5
        With srcWS
            .Range("A2").Copy Sheets(x).Range("A2")
            .Cells(2, y).Resize(LastRow - 1, 3).Copy Sheets(x).Range("F2")
            y = y + 3
        End With
    Next x
    Application.ScreenUpdating = True
End Sub
 
Upvote 0
Solution

Forum statistics

Threads
1,214,938
Messages
6,122,346
Members
449,080
Latest member
Armadillos

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