Practing vba code with copy and pasting , need help

ILeonFF

New Member
Joined
Jun 20, 2018
Messages
18
How do i go about consolidating this VBA Code for copying and pasting

Code:
Sub Button24_Click()
Sheets("General Information").Select
    ActiveWindow.SmallScroll Down:=27
    Range("D53:F53").Select
    Selection.Copy
    Sheets("Mechanical Design Summary").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False

    Range("B3").Select
    Sheets("General Information").Select
    Range("D55:F55").Select
    Application.CutCopyMode = False
    Selection.Copy
    Sheets("Mechanical Design Summary").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False

    Range("B4").Select
    Sheets("General Information").Select
    Range("D56:F56").Select
    Application.CutCopyMode = False
    Selection.Copy
    Sheets("Mechanical Design Summary").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False

    Range("B5").Select
    Sheets("FA-PCIF Header").Select
    Application.CutCopyMode = False
    Selection.Copy
    Sheets("Mechanical Design Summary").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False

    Range("B6").Select
    Sheets("General Information").Select
    ActiveWindow.SmallScroll Down:=-27
    Range("D17").Select
    Application.CutCopyMode = False
    Selection.Copy
    Sheets("Mechanical Design Summary").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False

    Range("B7").Select
    Sheets("General Information").Select
    Range("E17:F17").Select
    Application.CutCopyMode = False
    Selection.Copy
    Sheets("Mechanical Design Summary").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False

    Range("B8").Select
    Sheets("General Information").Select
    Range("D19").Select
    Application.CutCopyMode = False
    Selection.Copy
    Sheets("Mechanical Design Summary").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False

    Range("B9").Select
    Sheets("General Information").Select
    Range("D12").Select
    Application.CutCopyMode = False
    Selection.Copy
    Sheets("Mechanical Design Summary").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False

    Range("B10").Select
    Sheets("General Information").Select
    ActiveWindow.SmallScroll Down:=9
    Range("D33").Select
    Application.CutCopyMode = False
    Selection.Copy
    Sheets("Mechanical Design Summary").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
Range("B11").Select
    Sheets("General Information").Select
    Range("D20:K23").Select
    Application.CutCopyMode = False
    Selection.Copy
    Sheets("Mechanical Design Summary").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("B12").Select

    Sheets("General Information").Select
    ActiveWindow.SmallScroll Down:=15
    Range("D39").Select
    Application.CutCopyMode = False
    Selection.Copy
    Sheets("Mechanical Design Summary").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("B16").Select

End Sub
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
What would determine when the macro runs?
 
Upvote 0
Open up the VBE, goto ThisWorkbook module, select the dropdown called general & select Workbook, then select the other dropdown & select Before Save
In the code segment that appears put
Code:
Call Macro4
 
Upvote 0
Open up the VBE, goto ThisWorkbook module, select the dropdown called general & select Workbook, then select the other dropdown & select Before Save
In the code segment that appears put
Code:
Call Macro4

Thank you once again
 
Upvote 0
You're welcome

Is it possible that when i save a workbook, a macro would look at a cell and save it as what is ever in that cell?

Current file name: Applications_Form
What i want i am looking to do is, look at K1 (123456) and add it to the original file name so when i execute the save command it would look like this;
New File Name: 123457_Applications_Form.
 
Upvote 0
As this is a completely different question, you need to start a new thread.
 
Upvote 0

Forum statistics

Threads
1,223,234
Messages
6,170,891
Members
452,366
Latest member
TePunaBloke

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