VBA: Copy & Paste information from another template

SkywardPalm

Board Regular
Joined
Oct 23, 2021
Messages
61
Office Version
  1. 365
Platform
  1. Windows
Looking to copy the contents of one sheet that has a filled out template into a new sheet without changing the template (maintaining highlights), and without the formatting. The letters represent identifiers that will have the information pasted to the right of each. Here's the path I am currently taking.. was wondering if there is a more efficient method to do this.

VBA Code:
    Dim wksCurrent       As Worksheet            ' Current sheet
    Dim wksPrevious     As Worksheet            ' Previous sheet

    Set wksCurrent = ThisWorkbook.Sheets(1)
    Set wksPrevious = ThisWorkbook.Sheets(3)
        
    wksPrevious.Range("C4:C10").Copy
    wksCurrent.Range("C4").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
        
    wksPrevious.Range("E4:E10").Copy
    wksCurrent.Range("E4").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
        
    wksPrevious.Range("H4:I10").Copy
    wksCurrent.Range("H4").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    
    wksPrevious.Range("K4:L10").Copy
    wksCurrent.Range("K4").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False

Template.xlsm
ABCDEFGHIJKLMN
3
4ADFL
5BEGCC:
6HCC:
7ICC:
8J
9CK
10
11
12
13MR
14NS
15T
16U
17O$ -V
18P
19Q
20W
21
22
23
24
Destination
Cell Formulas
RangeFormula
C17C17=L80


For the below section of the template is where a list of sections will be imported, the amount of sections can change so I was also wondering if there were a dynamic way to import that particular row information. (Possibly insert that data and remove excess rows, while maintaining the cell formula above?)

Template.xlsm
ABCDEFGHIJKLMN
30
31Section List
32SECTDescriptionNotesTime InTime OutHrs. WorkedCurrent Template TotalPrevious Template Total Difference
33First SECTION>>>>0:00$ -$ -
340:00$ -$ -
350:00$ -$ -
360:00$ -$ -
370:00$ -$ -
380:00$ -$ -
390:00$ -$ -
400:00$ -$ -
410:00$ -$ -
420:00$ -$ -
430:00$ -$ -
440:00$ -$ -
450:00$ -$ -
460:00$ -$ -
470:00$ -$ -
480:00$ -$ -
490:00$ -$ -
500:00$ -$ -
510:00$ -$ -
520:00$ -$ -
530:00$ -$ -
540:00$ -$ -
550:00$ -$ -
560:00$ -$ -
570:00$ -$ -
580:00$ -$ -
590:00$ -$ -
600:00$ -$ -
610:00$ -$ -
620:00$ -$ -
630:00$ -$ -
640:00$ -$ -
650:00$ -$ -
660:00$ -$ -
670:00$ -$ -
680:00$ -$ -
690:00$ -$ -
700:00$ -$ -
710:00$ -$ -
720:00$ -$ -
730:00$ -$ -
740:00$ -$ -
750:00$ -$ -
760:00$ -$ -
770:00$ -$ -
780:00$ -$ -
79**NO NEW SECTIONS AFTER THIS**
80$ -$ -$ -$ -
Destination
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
For your first question here is the way I do copy Paste:
This is for just one of yours.
You should see how it works.
For scripts like this I never use "Set"
VBA Code:
Sub My_Way()
'Modified 5/18/2022  4:28:02 PM  EDT

Sheets(1).Range("C4:C10").Copy: Sheets(2).Range("C4").PasteSpecial xlPasteValues

Application.CutCopyMode Mode = False
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,920
Messages
6,122,279
Members
449,075
Latest member
staticfluids

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