Paste automatically content from a table with contiguous columns in another with another column between each one of them

Status
Not open for further replies.

vladimiratanasiu

Active Member
Joined
Dec 17, 2010
Messages
348
Office Version
  1. 365
  2. 2021
Platform
  1. Windows
Hello!

I have two tables, with similar content in them. In Table 1, the values are inserted in cells of contiguous columns. Table 2 has one more column, added supplementary after each column of Table 1. My question is how could I copy the content of Table 1, and paste it automatically in Table 2, ignoring the empty columns? I mention that the my tables are very large and this is a repetitive operation. Thank you!

Table 1
123
AAAAAA
BBBBBB
CCCCCC
DDDDDD
EEEEEE
FFFFFF
GGGGGG


Table 2
123
AAAAAA
BBBBBB
CCCCCC
DDDDDD
EEEEEE
FFFFFF
GGGGGG
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
kindly try code below
VBA Code:
Sub vladimiratanasiu()

    Dim WSCopy As Worksheet, TwsCopy As Worksheet
    Dim LRow As Long
    Dim iCTR As Integer

Application.ScreenUpdating = False

    Set WSCopy = Sheets("SheetX")
    Set TwsCopy = Sheets("SheetY")
    WSCopy.Activate
    LRow = Cells(rows.Count, 1).End(xlUp).Row
   
    iCTR = 2
    Do While iCTR < LRow
        TwsCopy.Range("A" & iCTR).Value = WSCopy.Range("A" & iCTR).Value
        TwsCopy.Range("C" & iCTR).Value = WSCopy.Range("C" & iCTR).Value
        TwsCopy.Range("E" & iCTR).Value = WSCopy.Range("D" & iCTR).Value
        iCTR = iCTR + 1
    Loop
   
Application.ScreenUpdating = True

MsgBox "TASK Completed!", vbInformation, " vladimiratanasiu "

End Sub
 
Upvote 0
Thank you for the quick response! I tried the macro, but it returns me the Error 9. As I mentioned, my tables are larger and more complex. I posted this message about one week ago, but didn't get any answer yet. It includes the sheets Employees scheduling - general list (see Employees scheduling - general list .xlsx) and Employees scheduling - production departments list (see Employees scheduling - production departments list .xlsx), both of them presenting the scheduling of employees from a firm. The general list (shown partially in the first image) is the source file, from which are exported data to the production departments one (e.g. Rademaker and Fritsch departments – see image 2 and 3). The staff activity is organized on days (date / week day), shifts (1,2,3) and departments. Every department has a permanent and an auxiliary team, described by a specific code of activity (member ID). The general list integrates all elements in a single table, filled continuously with new data from next day(s) or other departments. On the other hand, the destination files have identical information structured on departments (e.g. Fritsch, Rademaker, etc.). Giving the continuous changes of staff scheduling, I need a solution (macro, formulas etc.) to update automatically in each destination sheet the counterpart data from the source file, that are to be added in every next day (e.g. columns 2/3/2022, 3/3/2022 etc.). I would be very grateful to you if you cold find a solution at least for one module (e.g. Fritsch, rademaker etc.).

Thank you!



General list.png



Rademaker department list.png



Fritsch department list.png

 
Last edited:
Upvote 0
Duplicate to: Copy content from next columns and paste it in alternative ones

In future, please do not post the same question multiple times. Per Forum Rules (#12), posts of a duplicate nature will be locked or deleted.

In relation to your question here, I have closed this thread so please continue in the linked thread. If you do not receive a response, you can "bump" it by replying to it yourself, though we advise you to wait 24 hours before doing so, and not to bump a thread more than once a day.
 
Upvote 0
Status
Not open for further replies.

Forum statistics

Threads
1,224,835
Messages
6,181,245
Members
453,026
Latest member
cknader

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