Results 1 to 3 of 3

Create Macro to move values from the current sheet in which the macro is activated

Threaded View

Turkish1801 Create Macro to move values... 12-05-2013, 03:58 PM
Chriz Re: Create Macro to move... 12-06-2013, 03:09 AM
Turkish1801 Re: Create Macro to move... 12-06-2013, 06:11 PM
  1. #1
    Registered User
    Join Date
    12-05-2013
    Location
    Boston/Pittsburgh
    MS-Off Ver
    Excel 2007
    Posts
    3

    Create Macro to move values from the current sheet in which the macro is activated

    Hi Everyone,
    First time user here, and pretty new to the Macro element of Excel (and by pretty new, I mean a few hours). What I'm trying to do is pretty simple, I believe. Here is the situation

    1. I have several sheets, that have within them summing totals. What I'm trying to do is create a macro that, once I press it on a given sheet, it will take the values from certain cells in THAT sheet and move them into a preformatted sheet, named "End of Day Reports". I averaged some of the values from the original sheet when displaying in the "End of Day Report". The preformatted sheet's name will not change, but the sheets that the data is coming from will be different each day. I though it would be easiest to create a macro button in each sheet, that will reference the same macro, moving the values from the cells within that sheet to the pre-formatted sheet.

    I tried to use the macro-record function to accomplish this. As I feared, the macro references the sheets by name, which I think is my biggest problem. I have posted what I did so far below:

    Sub End_of_Day()
    '
    ' End_of_Day Macro
    ' moves from this sheet to the end of day report
    '
    ' Keyboard Shortcut: Ctrl+p
    '
        Range("G2").Select
        Selection.Copy
        Sheets("End of Day Reports").Select
        Range("B4").Select
        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
            :=False, Transpose:=False
        Sheets("Day 1").Select
        Range("T2").Select
        Application.CutCopyMode = False
        Selection.Copy
        Sheets("End of Day Reports").Select
        Range("B5").Select
        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
            :=False, Transpose:=False
        Sheets("Day 1").Select
        Range("K2").Select
        Application.CutCopyMode = False
        Selection.Copy
        Sheets("End of Day Reports").Select
        Range("B6").Select
        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
            :=False, Transpose:=False
        Sheets("Day 1").Select
        Range("E2").Select
        Application.CutCopyMode = False
        Selection.Copy
        Sheets("End of Day Reports").Select
        Range("C4").Select
        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
            :=False, Transpose:=False
        Sheets("Day 1").Select
        Range("T2").Select
        Application.CutCopyMode = False
        Selection.Copy
        Sheets("End of Day Reports").Select
        Range("C5").Select
        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
            :=False, Transpose:=False
        Sheets("Day 1").Select
        Range("I2").Select
        Application.CutCopyMode = False
        Selection.Copy
        Sheets("End of Day Reports").Select
        Range("C6").Select
        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
            :=False, Transpose:=False
        ActiveWindow.ScrollWorkbookTabs Sheets:=-1
        Sheets("Day 1").Select
        Range("Q2").Select
        Application.CutCopyMode = False
        Selection.Copy
        Range("O2").Select
        Application.CutCopyMode = False
        Selection.Copy
        Sheets("End of Day Reports").Select
        Range("B9").Select
        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
            :=False, Transpose:=False
        Sheets("Day 1").Select
        Range("V2").Select
        Application.CutCopyMode = False
        Selection.Copy
        Sheets("End of Day Reports").Select
        Range("B10").Select
        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
            :=False, Transpose:=False
        Range("E4:F4").Select
        Application.CutCopyMode = False
        ActiveCell.FormulaR1C1 = "=AVERAGE('day1'!R[3]C[12]:R[421]C[12])"
        Range("E4:F4").Select
        ActiveCell.FormulaR1C1 = "=AVERAGE('Day 1'!R[3]C[12]:R[421]C[12])"
        Range("E6:F6").Select
        ActiveCell.FormulaR1C1 = "=AVERAGE('Day 1'!R[1]C[13]:R[419]C[13])"
        Range("E8:F8").Select
        ActiveCell.FormulaR1C1 = "=AVERAGE('Day 1'!R[-1]C[15]:R[417]C[15])"
        Range("E10:F10").Select
        ActiveCell.FormulaR1C1 = "=AVERAGE('Day 1'!R[-3]C[14]:R[415]C[14])"
        Range("E11").Select
    End Sub
    There might be some superfluous commands in there, as I may have clicked around more than I needed to, and made some mistakes with the formulas. Any help anyone could give me would be extremely welcome. I don't know if there is a way to tag the sheet you are in as the "active sheet", or if there is a way to reference the previous sheet, as I'll only be pulling from one sheet and sending it to another. Not sure if those are possible, I've tried googling it but had very little success, so figured I'd talk to the experts. If someone can't help me with my specific sheet, perhaps they could point me to a macro that seeks to accomplish a similar thing? Thank you so much guys, hope to talk with you soon!

    Matteo

    (edit) I've done a more through reading of the rules (I apologize, I should have done so before) and have made some changes to my post. Additionally, here is a sample worksheet. As I mentioned earlier, I'd like the macro to transfer data from the active current sheet (there are two sheets in the worksheet I have attached, but there will be 20 in the final one) to the last sheet, which will always be called "End of Day Reports"

    Thanks again!
    Attached Files Attached Files
    Last edited by Turkish1801; 12-05-2013 at 04:38 PM. Reason: added tag to code

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Macro: Move Values To New Sheet
    By MR22 in forum Excel General
    Replies: 3
    Last Post: 06-01-2012, 11:18 AM
  2. Macro: Move Values To New Sheet
    By MR22 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-01-2012, 11:03 AM
  3. [SOLVED] Macro copying values and sheet names of all activated sheets
    By Rosixks in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-07-2011, 06:16 PM
  4. Need help with Macro to run on activated sheet
    By sjsfiji in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-17-2008, 07:41 PM
  5. Error sheet when macro's are not activated
    By jgmiddel in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-22-2006, 05:28 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1