+ Reply to Thread
Results 1 to 11 of 11

MACRO to retain a copy of a certain range to different sheet collectively

  1. #1
    Forum Contributor
    Join Date
    11-25-2018
    Location
    Philippines
    MS-Off Ver
    Ms Office 365
    Posts
    217

    MACRO to retain a copy of a certain range to different sheet collectively

    I have uploaded a sample file with 2 sheets on it. The PO and the PO_VAULT.

    Here is the thing, I wonder if it is possible to have a macro on this whenever activated, the data on PO sheet cell A1:M180 will be duplicated to PO_VAULT sheet on cell cell A1:M180 (Just like a copy and paste whilst keeping the source column width.
    The data on PO sheet changes from one transaction to another so for the 2nd transaction, when the macro is activated, since the first transaction has been copied on PO_VAULT sheet at cell A1:M180 and it covers from column A to M, the next transaction will be copied and pasted (whilst keeping the column width) on cell N1 to X180,
    3rd will be on:
    columns Y1 to AI180
    4th will be on:
    Columns AJ1 to AT180 and so on...

    Is it possible?

    Edited:

    Please Login or Register  to view this content.
    This code works but could someone add a pop up msg if the value in "PO_VAULT" sheet row 7 has a duplicated Po control number? These PO numbers are located first at cell I7, second is v7, third is AI7, next AV7 and so on (Same interval) with a msg pop up of "Duplicated Purchase order number detected, Delete it first from the vault." and it will cancel the effect or function of this macro
    Attached Files Attached Files
    Last edited by archvanarl; 03-21-2021 at 05:11 AM.

  2. #2
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,810

    Re: MACRO to retain a copy of a certain range to different sheet collectively

    Try:
    Please Login or Register  to view this content.
    You can say "THANK YOU" for help received by clicking the Star symbol at the bottom left of the helper's post.
    Practice makes perfect. I'm very far from perfect so I'm still practising.

  3. #3
    Forum Contributor
    Join Date
    11-25-2018
    Location
    Philippines
    MS-Off Ver
    Ms Office 365
    Posts
    217

    Re: MACRO to retain a copy of a certain range to different sheet collectively

    Thank you it worked!hmm can i ask more? Could you add a pop up msg "Purchase Order has been vaulted"?

  4. #4
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,810

    Re: MACRO to retain a copy of a certain range to different sheet collectively

    Try:
    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    11-25-2018
    Location
    Philippines
    MS-Off Ver
    Ms Office 365
    Posts
    217

    Re: MACRO to retain a copy of a certain range to different sheet collectively

    I have one more problem, the data on PO are linked from the other sheets. Is there a way to copy and paste it as values whilst keeping the source column width because in this code copies the formula of that table?

    Edit: I found a solution

    Sub CopyData()
    Application.ScreenUpdating = False
    Dim lCol As Long, srcWS As Worksheet, desWS As Worksheet
    Set srcWS = Sheets("PO")
    Set desWS = Sheets("PO_VAULT")
    lCol = desWS.Cells(19, Columns.Count).End(xlToLeft).Column + 1
    If lCol = 2 Then lCol = 1
    srcWS.Range("A1:M180").Copy
    With desWS.Cells(1, lCol)
    .PasteSpecial xlPasteValues
    .PasteSpecial xlPasteColumnWidths
    .PasteSpecial xlPasteFormats
    End With
    MsgBox "Purchase Order has been vaulted."
    Application.CutCopyMode = False
    Application.ScreenUpdating = True
    End Sub
    Last edited by archvanarl; 03-12-2021 at 10:54 AM.

  6. #6
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,810

    Re: MACRO to retain a copy of a certain range to different sheet collectively

    Try:
    Please Login or Register  to view this content.

  7. #7
    Forum Contributor
    Join Date
    11-25-2018
    Location
    Philippines
    MS-Off Ver
    Ms Office 365
    Posts
    217

    Re: MACRO to retain a copy of a certain range to different sheet collectively

    Hi, thanks for the help but could you make some changes or modifications of the code I updated my message at post #1.
    Last edited by archvanarl; 03-21-2021 at 05:12 AM.

  8. #8
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,810

    Re: MACRO to retain a copy of a certain range to different sheet collectively

    Are you saying that if the PO No. in I7 already exists in the PO_VAULT sheet, you want all the data for that PO No. in the PO_VAULT sheet replaced with the current data in the PO sheet for that Po No.?

  9. #9
    Forum Contributor
    Join Date
    11-25-2018
    Location
    Philippines
    MS-Off Ver
    Ms Office 365
    Posts
    217

    Unhappy Re: MACRO to retain a copy of a certain range to different sheet collectively

    Quote Originally Posted by Mumps1 View Post
    Are you saying that if the PO No. in I7 already exists in the PO_VAULT sheet, you want all the data for that PO No. in the PO_VAULT sheet replaced with the current data in the PO sheet for that Po No.?
    PO No. could be anywhere at row 7 with an interval ir I7, V7, AI7, AV7...

    It is okay not to be replaced because it may be too complicated because the data in each table with corresponding PO no. are stacked or collected there horizontally. Just a pop up msg that it is already existed and will cancel the function of the macro to avoid duplicate PO control nos in PO_VAULT.

    If you propose to replace the data in that existing PO number at PO_VAULT, it's okay also but will also have a pop up of a YES or NO if you want to replace.. whichever is most possible for you sir.
    Last edited by archvanarl; 03-21-2021 at 10:39 AM.

  10. #10
    Forum Contributor
    Join Date
    11-25-2018
    Location
    Philippines
    MS-Off Ver
    Ms Office 365
    Posts
    217

    Re: MACRO to retain a copy of a certain range to different sheet collectively

    Bump for this

  11. #11
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,810

    Re: MACRO to retain a copy of a certain range to different sheet collectively

    Try:
    Please Login or Register  to view this content.

+ 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. Saving A Copy of a Sheet in a New Workbook and Retain the macro?
    By Norcal1 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-09-2018, 08:05 PM
  2. [SOLVED] Copy range to a new workbook & retain range names
    By Aland2929 in forum Excel General
    Replies: 2
    Last Post: 09-28-2017, 02:48 AM
  3. [SOLVED] Excel 2013: Copy Pivot Table Values to New Sheet and Retain Formatting
    By greatjobtoday in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 03-27-2015, 08:07 AM
  4. copy and retain information from a data entry sheet to trending sheet
    By thuddleston11 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-22-2012, 11:13 AM
  5. Replies: 2
    Last Post: 12-18-2012, 05:22 AM
  6. 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
  7. [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