Copy/Pasting rows of a table to specific cells of a separate worksheet template and exporting as a new file.

DjentChicken

New Member
Joined
May 9, 2024
Messages
1
Office Version
  1. 2010
Platform
  1. Windows
I guess I'm looking to see if this is even possible first, I've put together some VBA code but I'm having issues with it executing. My goal with this code is to take a database table I've compiled and make each row of this table export into a separate workbook template I've created. I need specific cells in the data table row to be pasted into specific cells of my template. For example I need cell A5 from my master table be pasted into D5 of my template workbook. I'm further trying to automate this process by possibly not having to change the code every time I want to export specific rows. I'm not sure if it's possible for a pop up to instruct to select a row/rows for exporting into separate files. I've supplied what code I've been working on below (I won't be surprised if I'm told to scrap it). I've also supplied my master data table "Master Information List" Workbook, as well as the template workbook " Spec Sheet Template". I'd appreciate any and all guidance, I hope something like this is possible.


VBA Code:
Option Explicit

Private Sub EntireColumnRange()

    Dim wb As Workbook: Set wb = ThisWorkbook
    Dim sws As Worksheet: Set sws = wb.Worksheets(1)
    
    '"Tag" (A"#")[master information List] copy/paste -> "Tag Number" (D5) [Spec Sheet template]
    wb.sws("Master information List").rg("A5").Copy Destination:=sws("Spec Sheet template").rg("D5").PasteSpecial

    'Header (B-F)
    ThisWorkbook.Worksheets("Master information List").Range("B5:F5").Copy Destination:=Worksheets("Spec Sheet template").Range("H1:H2, J3, H3:H4")

    'Info (G-J)
    ThisWorkbook.Worksheets("Master information List").Range("G5:J5").Copy Destination:=Worksheets("Spec Sheet template").Range("D6:D9")

    'Body (K-S)
    ThisWorkbook.Worksheets("Master information List").Range("K5:S5").Copy Destination:=Worksheets("Spec Sheet template").Range("D10:D18")

    'Trim (T-Y)
    ThisWorkbook.Worksheets("Master information List").Range("T5:Y5").Copy Destination:=Worksheets("Spec Sheet template").Range("D19:D24")

    'Actuator (Z-AF)
    ThisWorkbook.Worksheets("Master information List").Range("Z5:AF5").Copy Destination:=Worksheets("Spec Sheet template").Range("D29:D35")

    'Accessories (AG-AO)
    ThisWorkbook.Worksheets("Master information List").Range("AG5:AO5").Copy Destination:=Worksheets("Spec Sheet template").Range("D40:D48")

    'Service (AP-BD)
    ThisWorkbook.Worksheets("Master information List").Range("AP5:BD5").Copy Destination:=Worksheets("Spec Sheet template").Range("E52,D52,E53,F53,G53,E54,F54,G54,E55,F55,G55,E56,E57,E58,E59")

    'Notes (BE-BH)
    ThisWorkbook.Worksheets("Master information List").Range("BE5:BH5").Copy Destination:=Worksheets("Spec Sheet template").Range("C66:C69")

End Sub

"Master Information List"
master list example coding.xlsm
ABCDEFGHIJKLMNOPQRSTUVWXYZAAABACADAEAFAGAHAIAJAKALAMANAOAPAQARASATAUAVAWAXAYAZBABBBCBDBEBFBGBH
1TagHeaderInfoBodyTrimActuatorAccessoriesServiceNotes
2D5H1H2J3H3h4D6D7D8D9D10D11D12D13D14D15D16D17D18D19D20D21D22D23D24D29D30D31D32D33D34D35D40D41D42D43D44D45D46D47D48E52D52E53F53G35E54F54G54E55F55G55E56E57E58E59C66C67C68C69
3TAG # PJ #: P.R. #:DATE: By:Sheet #PLANTSERVICELINE/VESSEL #P&ID #PIPE SIZE / SCH / IDTYPESIZEMATERIALBONNET TYPE / MAT.END CONNECTION & RATINGBOLTING MATERIALBEARINGS / GASKETPACKINGSIZETRIM CHAR.PLUG/BALL/DISK MAT.SEAT MAT.STEM Mat.LEAKAGE CL.TYPE OF ACTUATORFLOW ACT.FAIL POS.SOLENOID ENERGIZE TO PLANT AIR PRESS MIN & MAX REGULATOR W/GAUGEAIR FILTERSOLENOID VALVE LIMIT SWITCHESNEC CLASSIFICATIONHANDWHEELPOSITION INDICATORAIR SET WITH GUAGETUBING FITTINGSSS TAGPMIfluidphaseflow maxflow normflow mintemp maxtemp normtemp minpres. Maxpres. Normpres. Minspec. grav. @ op.op. viscosityallow. Deci.shut off pres.note 1note 2note3 note4
4
5ROV-0003 08/07/23TR1LLDPE H2 FROM TRUCK IN HDPE H2-90854-ABA-2"-N LLPI-90019 2" / SCH 40 TRUNNION 2" WCB (MARINE GRADE PAINT) WCB (MARINE GRADE PAINT) 2" x 300# RF MANUF STD BY MFR PTFE BY MFR FULL BORE 304 SS REINFORCED PTFE WITH METAL CARRIER RING 304 SS VI MANUF STD OPEN CLOSE OPEN 60 PSI / 120 PSI ALL METAL CONST. ALUM W/GAUGE COALESCING/ 10 MICRON / ALL METAL CONSTRUCTURE ASCO 3 WAY, 24VDC I.S. NEMA 4X 1 N.O. & 1 N.C. : DRY CONTACT EACH I.S. CLASS 1 DIV. 2 GRP. B-D DECLUTCHABLE MANUAL W/ HAND WHEEL WITH NON-RELEIF TYPE PARKER CPI YES REQUIRED H2 40 21.3 65 50 635 480 0.009 <85 635 1)USE EPOXY PAINT ON ALL C.S. PARTS OF VALVE, ACTUATOR, & HANDWHEEL 2) VALVE SIZING AND DIMENSIONAL DWG REQUIRED W/QUOTE 3) MUST MEET API FIRESAFE 607 7TH ED. STANDARDS
Master information List


"Spec Sheet Template"
master list example coding.xlsm
ABCDEFGHIJ
1INSTRUMENT SPECIFICATION PJ NUMBER:
2ON/OFF VALVE P.R. NUMBER:
3 BY:DATE:
4SHEET NO.REV:
51TAG NUMBERMEET SPEC YES / NOEXPLAIN
62PLANT
73SERVICEIF
84LINE/VESSEL NUMBERNO
95P&ID NUMBER
105BODYPIPE SIZE / SCH / ID
116TYPE
127SIZE
138BODY MATERIAL
149BONNET TYPE / MATERIAL
1510END CONNECTION & RATING
1611BOLTING MATERIAL
1712BEARINGS / GASKET
1813PACKING
1914TRIMSIZE
2015TRIM CHARACTERISTIC
2116PLUG/BALL/ DISK MATERIAL
2217SEAT MATERIAL
2318STEM MATERIAL
2419LEAKAGE CLASS
2520
2621
2722
2823
2924ACTUATORTYPE OF ACTUATOR
3025FLOW ACTION TO
3126FAIL POSITION
3227SOLENOID ENERGIZE TO
3328PLANT AIR PRESS MIN & MAX
3429REGULATOR W/GAUGE
3530AIR FILTER
3631
3732
3833
3934
4035ACCESSORIESSOLENOID VALVE
4136LIMIT SWITCHES
4237NEC CLASSIFICATION
4338HANDWHEEL
4439POSITION INDICATOR
4540AIR SET WITH GUAGE
4641TUBING FITTINGS
4742SS TAG
4843PMI
4944
5045
5146SERVICEUNITSMAXIMUMNORMALMINIMUM
5247FLUID / PHASE
5348FLOW RATE LB/HR
5449TEMP DEG F
5550PRESSURE PSIG
5651SPEC GRAVITY. @ OPERATION--
5752OPERATING VISCOSITY--
5853ALLOWABLE /PREDICTED SOUND dBA
5954SHUT OFF PRESSURE PSIG
6055
6156
6257
6358
6459
6560
6661NOTES
6762
6863
6964
70
71
72
Spec Sheet template
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.

Forum statistics

Threads
1,223,886
Messages
6,175,189
Members
452,616
Latest member
intern444

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