Specify Current worksheet in a Macro

minkthemonk

New Member
Joined
Oct 11, 2017
Messages
2
Hello everyone!

I'm trying to automate the copy process of a certain Sheet to another Sheet in order to create a sum up of a day in my company.

So:

I have a workbook with 32 Sheets.
31 Sheets for each day of the month.
1 Sheet that works as a "template" to sum up the data of each day.
All 31 Sheets have the name of the respctive day of the month (1,2,3...31)
The last Sheet, called Fecho represents the "template" where I want the data to be copied in order to Print it after.

I want to copy some cell contents (the result of various calculations) to specific cells is the Sheet "Fecho".
This is very simple to do, but I'm trying to make only one macro instead of 31. (1 macro for each Sheet)
Basically I need to change the Sheet "1" or "17" whatever to "current sheet" (?) Or am I saying something really stupid? :rofl:

Can you please explain me how to do it?

Here's my code for sheet "1" :

Sub GerarFC()
'
' GerarFC Macro
'


'
Range("C7:F12").Select
Selection.Copy
Sheets("Fecho").Select
Range("B2:E7").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("1").Select
Range("B26:H26").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Fecho").Select
Range("A12:G12").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("1").Select
Range("I26").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Fecho").Select
Range("B15").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("1").Select
Range("K26:M26").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Fecho").Select
Range("C15:E15").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("1").Select
Range("K23:L23").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Fecho").Select
Range("G25:H25").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
End Sub


Thank you very much.
Best regards,
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
Hi & welcome to the board
This will copy from the active sheet
Code:
Sub GerarFC()
'
' GerarFC Macro
'


    With ActiveSheet
        .Range("C7:F12").Copy
        Sheets("Fecho").Range("B2:E7").PasteSpecial Paste:=xlPasteValues, _
            Operation:=xlNone, SkipBlanks:=False, Transpose:=False
        .Range("B26:H26").Copy
        Sheets("Fecho").Range("A12:G12").PasteSpecial Paste:=xlPasteValues, _
            Operation:=xlNone, SkipBlanks:=False, Transpose:=False
        .Range("I26").Copy
        Sheets("Fecho").Range("B15").PasteSpecial Paste:=xlPasteValues, _
            Operation:=xlNone, SkipBlanks:=False, Transpose:=False
        .Range("K26:M26").Copy
        Sheets("Fecho").Range("C15:E15").PasteSpecial Paste:=xlPasteValues, _
            Operation:=xlNone, SkipBlanks:=False, Transpose:=False
        .Range("K23:L23").Copy
        Sheets("Fecho").Range("G25:H25").PasteSpecial Paste:=xlPasteValues, _
            Operation:=xlNone, SkipBlanks:=False, Transpose:=False
    End With
    
End Sub
 
Last edited:
Upvote 0
Hi & welcome to the board
This will copy from the active sheet
Code:
Sub GerarFC()
'
' GerarFC Macro
'


    With ActiveSheet
        .Range("C7:F12").Copy
        Sheets("Fecho").Range("B2:E7").PasteSpecial Paste:=xlPasteValues, _
            Operation:=xlNone, SkipBlanks:=False, Transpose:=False
        .Range("B26:H26").Copy
        Sheets("Fecho").Range("A12:G12").PasteSpecial Paste:=xlPasteValues, _
            Operation:=xlNone, SkipBlanks:=False, Transpose:=False
        .Range("I26").Copy
        Sheets("Fecho").Range("B15").PasteSpecial Paste:=xlPasteValues, _
            Operation:=xlNone, SkipBlanks:=False, Transpose:=False
        .Range("K26:M26").Copy
        Sheets("Fecho").Range("C15:E15").PasteSpecial Paste:=xlPasteValues, _
            Operation:=xlNone, SkipBlanks:=False, Transpose:=False
        .Range("K23:L23").Copy
        Sheets("Fecho").Range("G25:H25").PasteSpecial Paste:=xlPasteValues, _
            Operation:=xlNone, SkipBlanks:=False, Transpose:=False
    End With
    
End Sub

Awesome!!! Thank you so much Fluff!! You rock! :cool:
 
Upvote 0
Glad to help & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,223,162
Messages
6,170,431
Members
452,326
Latest member
johnshaji

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