+ Reply to Thread
Results 1 to 5 of 5

Macro to copy a range in a sheet...

Hybrid View

  1. #1
    Registered User
    Join Date
    02-26-2015
    Location
    BC
    MS-Off Ver
    Office 365
    Posts
    3

    Exclamation Macro to copy a range in a sheet...

    I will start from top to bottom of what I need. FYI I am very very new to macros..

    I need to copy a template sheet "BLANK FR" and paste it at the end of all the other sheets in the workbook for a new day. I have a macro for this step and it works just fine:

    Sub CopyForemanReport()
    Dim WS As Worksheet, WB As Workbook
    Set WB = ActiveWorkbook
    Set WS = WB.Sheets("BLANK FR")
    WS.Copy After:=Sheets(WB.Sheets.Count)
    End Sub


    I have a summary sheet "Labour & Equipment Summary" with a range of cells in it that pulls data from the BLANK FR sheets that I create for each new day. So now, I need to copy the range of cells (A8:AS18) and paste that data below the summary range already on that sheet with a blank row in between. I only want to copy range (A8:AS18) every time - nothing more, nothing less. This is the macro I have set up for this step, except it copies the range I want plus everything I have added after it:

    Sub CopySummary()

    Dim LastRow As Long
    Dim destRng As Range

    Application.ScreenUpdating = False

    With Sheets("Labour & Equipment Summary")
    Set destRng = .Range("A" & .Cells(.Rows.Count, "A").End(xlUp).Row + 2)

    LastRow = Sheets("Labour & Equipment Summary").Range("C" & Rows.Count).End(xlUp).Row
    Sheets("Labour & Equipment Summary").Range("A8:AS18" & LastRow).Copy Destination:=destRng

    End With
    Application.ScreenUpdating = True
    End Sub


    Next, I need to update all of the formulas in the new summary range that I just pasted on the "Labour & Equipment Summary" sheet to reflect the new "BLANK FR (2)" sheet I just created, not any other range. I have a macro for this, but it updates the same range (B20:AR30) every time, not the new summary range I just pasted:

    Sub UpdateSummary2NewDay()
    '
    ' UpdateSummary2NewDay Macro
    '
    ' Keyboard Shortcut: Ctrl+l
    '
    Range("B20:AR30").Select
    ActiveWindow.ScrollColumn = 16
    ActiveWindow.ScrollColumn = 15
    ActiveWindow.ScrollColumn = 14
    ActiveWindow.ScrollColumn = 13
    ActiveWindow.ScrollColumn = 12
    ActiveWindow.ScrollColumn = 11
    ActiveWindow.ScrollColumn = 10
    ActiveWindow.ScrollColumn = 9
    ActiveWindow.ScrollColumn = 8
    ActiveWindow.ScrollColumn = 7
    ActiveWindow.ScrollColumn = 6
    ActiveWindow.ScrollColumn = 5
    ActiveWindow.ScrollColumn = 4
    ActiveWindow.ScrollColumn = 3
    ActiveWindow.ScrollColumn = 2
    ActiveWindow.ScrollColumn = 1
    Selection.Replace What:="BLANK FR", Replacement:="BLANK FR (2)", LookAt:= _
    xlPart, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
    ReplaceFormat:=False
    End Sub


    I hope someone understands what I need and can help me achieve it. As I said, I was just introduced to Macros yesterday and am quite impressed with how much I have accomplished already, just need to tweak it so it is perfect. AND if I could have all of these steps combined into one macro with a shortcut like (ctrl + j) that would be even better, versus 3 separate macros with 3 separate shortcuts. Thanks in advance!!

    I have attached the spreadsheet as well.

    Chantelle
    Attached Files Attached Files

  2. #2
    Forum Expert skywriter's Avatar
    Join Date
    06-09-2014
    Location
    USA
    MS-Off Ver
    365 Version 2409
    Posts
    2,789

    Re: Macro to copy a range in a sheet...

    Let me know how this works out.
    Attached Files Attached Files

  3. #3
    Registered User
    Join Date
    02-26-2015
    Location
    BC
    MS-Off Ver
    Office 365
    Posts
    3

    Red face Re: Macro to copy a range in a sheet...

    @skywriter..

    OMG, you are amazing. It works perfectly, thank you so much!!

  4. #4
    Forum Expert skywriter's Avatar
    Join Date
    06-09-2014
    Location
    USA
    MS-Off Ver
    365 Version 2409
    Posts
    2,789

    Re: Macro to copy a range in a sheet...

    Hold on a minute, I didn't see your request to combine them. I didn't combine them, it's better to leave them separate. But I've set this up so that control j will run them all.
    Just make sure there's not an FR2 sheet if you run this more than once, if you want to check that it doesn't paste more than you wanted and all that other stuff, delete the copy sheet first.
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    02-26-2015
    Location
    BC
    MS-Off Ver
    Office 365
    Posts
    3

    Wink Re: Macro to copy a range in a sheet...

    Thanks for going the extra mile and combining all the macros into one macro for me, but I was able to complete that step myself.

    Thanks again for all of your help!!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Macro to Copy a range from one sheet and sellect where to paste in another sheet
    By Bud Wilkinsonn in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-23-2013, 06:49 PM
  2. [SOLVED] Macro to copy range and paste to other sheet
    By Will29 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 01-13-2013, 01:26 PM
  3. Macro to copy and paste range form one sheet to next available row in 2nd sheet
    By bajdr47 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-21-2012, 11:47 PM
  4. Need MACRO to copy RANGE to new sheet
    By swilkinson1 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-18-2012, 11:46 AM
  5. [SOLVED] Macro: Dynamic creation of sheet based on cell value then copy range to the new sheet
    By BeachRock in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 03-15-2012, 11:31 AM

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