.copy .paste problem when pasting to tables

ENO111

New Member
Joined
Mar 11, 2018
Messages
1
Self taught... Needing some help pasting information from "DW" to tables... Code pastes to the tables correctly for "Range A" of target worksheet, but the table expands to the bottom of "Range A" when the information is pastes and "Range B,C,D,E, ETC" offsets below the previous range in the table of concern. Pic at bottom of post. Thanks!


Code:
[COLOR=#333333][FONT=Verdana]Dim DW As Worksheet[/FONT][/COLOR]
[COLOR=#333333][FONT=Verdana]Dim WFIT As Worksheet[/FONT][/COLOR]
[COLOR=#333333][FONT=Verdana]Dim EIT As Worksheet[/FONT][/COLOR]
[COLOR=#333333][FONT=Verdana]Dim PIT As Worksheet[/FONT][/COLOR]
[COLOR=#333333][FONT=Verdana]Dim BIT As Worksheet[/FONT][/COLOR]
[COLOR=#333333][FONT=Verdana]Dim MIT As Worksheet[/FONT][/COLOR]
[COLOR=#333333][FONT=Verdana]Dim N As Long[/FONT][/COLOR]
[COLOR=#333333][FONT=Verdana]Dim M As Long[/FONT][/COLOR]
[COLOR=#333333][FONT=Verdana]Dim O As Long[/FONT][/COLOR]
[COLOR=#333333][FONT=Verdana]Dim P As Long[/FONT][/COLOR]
[COLOR=#333333][FONT=Verdana]Set DW = Worksheets("DailyWorksheet")[/FONT][/COLOR]
[COLOR=#333333][FONT=Verdana]Set WFIT = Worksheets("WorkForceInformationTable")[/FONT][/COLOR]
[COLOR=#333333][FONT=Verdana]Set EIT = Worksheets("EquipmentInformationTable")[/FONT][/COLOR]
[COLOR=#333333][FONT=Verdana]Set PIT = Worksheets("ProjectInformationTable")[/FONT][/COLOR]
[COLOR=#333333][FONT=Verdana]Set BIT = Worksheets("BidItemInformationTable")[/FONT][/COLOR]
[COLOR=#333333][FONT=Verdana]Set MIT = Worksheets("MaterialInformationTable")[/FONT][/COLOR]

[COLOR=#333333][FONT=Verdana]Application.ScreenUpdating = False[/FONT][/COLOR]

[COLOR=#333333][FONT=Verdana]'Selects Cell C8 or Down 8 and Over 3[/FONT][/COLOR]

[COLOR=#333333][FONT=Verdana]N = Cells(8, 3).End(xlDown).Row[/FONT][/COLOR]

[COLOR=#333333][FONT=Verdana]'Contractor's WorkForce Section[/FONT][/COLOR]

[COLOR=#333333][FONT=Verdana]DW.Range("C8:C" & N).Copy[/FONT][/COLOR]
[COLOR=#333333][FONT=Verdana]WFIT.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues[/FONT][/COLOR]
[COLOR=#333333][FONT=Verdana]DW.Range("B8:B" & N).Copy[/FONT][/COLOR]
[COLOR=#333333][FONT=Verdana]WFIT.Cells(Rows.Count, 2).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues[/FONT][/COLOR]
[COLOR=#333333][FONT=Verdana]DW.Range("A8:A" & N).Copy[/FONT][/COLOR]
[COLOR=#333333][FONT=Verdana]WFIT.Cells(Rows.Count, 3).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues[/FONT][/COLOR]
[COLOR=#333333][FONT=Verdana]DW.Range("V8:V" & N).Copy[/FONT][/COLOR]
[COLOR=#333333][FONT=Verdana]WFIT.Cells(Rows.Count, 4).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues[/FONT][/COLOR]
[COLOR=#333333][FONT=Verdana]DW.Range("W8:W" & N).Copy[/FONT][/COLOR]
[COLOR=#333333][FONT=Verdana]WFIT.Cells(Rows.Count, 5).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues[/FONT][/COLOR]
[COLOR=#333333][FONT=Verdana]DW.Range("X8:X" & N).Copy[/FONT][/COLOR]
[COLOR=#333333][FONT=Verdana]WFIT.Cells(Rows.Count, 6).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues[/FONT][/COLOR]

[COLOR=#333333][FONT=Verdana]'Contractor's Equipment Section[/FONT][/COLOR]

[COLOR=#333333][FONT=Verdana]'Selects Cell G8 or Down 8 and Over 7[/FONT][/COLOR]
[COLOR=#333333][FONT=Verdana]M = Cells(8, 7).End(xlDown).Row[/FONT][/COLOR]
[COLOR=#333333][FONT=Verdana]DW.Range("G8:G" & M).Copy[/FONT][/COLOR]
[COLOR=#333333][FONT=Verdana]EIT.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues[/FONT][/COLOR]
[COLOR=#333333][FONT=Verdana]DW.Range("F8:F" & M).Copy[/FONT][/COLOR]
[COLOR=#333333][FONT=Verdana]EIT.Cells(Rows.Count, 2).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues[/FONT][/COLOR]
[COLOR=#333333][FONT=Verdana]DW.Range("Y8:Y" & M).Copy[/FONT][/COLOR]
[COLOR=#333333][FONT=Verdana]EIT.Cells(Rows.Count, 3).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues[/FONT][/COLOR]
[COLOR=#333333][FONT=Verdana]DW.Range("Z8:Z" & M).Copy[/FONT][/COLOR]
[COLOR=#333333][FONT=Verdana]EIT.Cells(Rows.Count, 4).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues[/FONT][/COLOR]
[COLOR=#333333][FONT=Verdana]DW.Range("AA8:AA" & M).Copy[/FONT][/COLOR]
[COLOR=#333333][FONT=Verdana]EIT.Cells(Rows.Count, 5).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues[/FONT][/COLOR]

[COLOR=#333333][FONT=Verdana]'Bid Items Installed Section[/FONT][/COLOR]

[COLOR=#333333][FONT=Verdana]'Selects Cell G19 or Down 19 and Over 7[/FONT][/COLOR]

[COLOR=#333333][FONT=Verdana]O = Cells(19, 2).End(xlDown).Row[/FONT][/COLOR]

[COLOR=#333333][FONT=Verdana]DW.Range("A19:A" & O).Copy[/FONT][/COLOR]
[COLOR=#333333][FONT=Verdana]BIT.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues[/FONT][/COLOR]
[COLOR=#333333][FONT=Verdana]DW.Range("B19:B" & O).Copy[/FONT][/COLOR]
[COLOR=#333333][FONT=Verdana]BIT.Cells(Rows.Count, 2).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues[/FONT][/COLOR]
[COLOR=#333333][FONT=Verdana]DW.Range("D19[/FONT][/COLOR]:D"[COLOR=#333333][FONT=Verdana] & O).Copy[/FONT][/COLOR]
[COLOR=#333333][FONT=Verdana]BIT.Cells(Rows.Count, 3).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues[/FONT][/COLOR]
[COLOR=#333333][FONT=Verdana]DW.Range("E19:E" & O).Copy[/FONT][/COLOR]
[COLOR=#333333][FONT=Verdana]BIT.Cells(Rows.Count, 4).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues[/FONT][/COLOR]
[COLOR=#333333][FONT=Verdana]DW.Range("V19:V" & O).Copy[/FONT][/COLOR]
[COLOR=#333333][FONT=Verdana]BIT.Cells(Rows.Count, 5).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues[/FONT][/COLOR]
[COLOR=#333333][FONT=Verdana]DW.Range("W19:W" & O).Copy[/FONT][/COLOR]
[COLOR=#333333][FONT=Verdana]BIT.Cells(Rows.Count, 6).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues[/FONT][/COLOR]
[COLOR=#333333][FONT=Verdana]DW.Range("X19:X" & O).Copy[/FONT][/COLOR]
[COLOR=#333333][FONT=Verdana]BIT.Cells(Rows.Count, 7).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues[/FONT][/COLOR]

[COLOR=#333333][FONT=Verdana]'Materials Used Section[/FONT][/COLOR]
[COLOR=#333333][FONT=Verdana]'Selects Cell G19 or Down 19 and Over 7[/FONT][/COLOR]

[COLOR=#333333][FONT=Verdana]P = Cells(19, 7).End(xlDown).Row[/FONT][/COLOR]

[COLOR=#333333][FONT=Verdana]DW.Range("G19:G" & P).Copy[/FONT][/COLOR]
[COLOR=#333333][FONT=Verdana]MIT.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues[/FONT][/COLOR]
[COLOR=#333333][FONT=Verdana]DW.Range("F19:F" & P).Copy[/FONT][/COLOR]
[COLOR=#333333][FONT=Verdana]MIT.Cells(Rows.Count, 2).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues[/FONT][/COLOR]
[COLOR=#333333][FONT=Verdana]DW.Range("J19:J" & P).Copy[/FONT][/COLOR]
[COLOR=#333333][FONT=Verdana]MIT.Cells(Rows.Count, 3).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues[/FONT][/COLOR]
[COLOR=#333333][FONT=Verdana]DW.Range("Y19:Y" & P).Copy[/FONT][/COLOR]
[COLOR=#333333][FONT=Verdana]MIT.Cells(Rows.Count, 4).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues[/FONT][/COLOR]
[COLOR=#333333][FONT=Verdana]DW.Range("Z19:Z" & P).Copy[/FONT][/COLOR]
[COLOR=#333333][FONT=Verdana]MIT.Cells(Rows.Count, 5).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues[/FONT][/COLOR]
[COLOR=#333333][FONT=Verdana]DW.Range("AA19:AA" & P).Copy[/FONT][/COLOR]
[COLOR=#333333][FONT=Verdana]MIT.Cells(Rows.Count, 6).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues[/FONT][/COLOR]

[COLOR=#333333][FONT=Verdana]End Sub[/FONT][/COLOR]



Picture is of WFIT worksheet after information is copied from DW worksheet.
 
Last edited by a moderator:

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
Cross-Posting
While we do not prohibit Cross-Posting on this site, we do ask that you please mention you are doing so and provide links in each of the threads pointing to the other thread (see rule 13 here along with the explanation: Forum Rules).
This way, other members can see what has already been done in regards to a question, and do not waste time working on a question that may already be answered.
Please provide links to all other sites you have asked this question on.
Thanks
 
Upvote 0

Forum statistics

Threads
1,223,908
Messages
6,175,306
Members
452,633
Latest member
DougMo

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