+ Reply to Thread
Results 1 to 4 of 4

Excel macro of copy paste that transale both line and column into a single line

  1. #1
    Registered User
    Join Date
    03-13-2024
    Location
    Montreal, QC, Canada
    MS-Off Ver
    MS Office 365
    Posts
    2

    Excel macro of copy paste that transale both line and column into a single line

    Hi all, I'm needing some help since I've tried multiple times to do it myself but was unable to achieve my goal.

    Here's what I'm trying to achieve :

    In my excel file, I have multiple Product sheet (ex : Product 1, Product 2). I need, when I change the date into the column F of each sheet, ask the user a question : Do you want to archive the data? If yes, we continue with the macro. If no, we bring back the date before the user change it and we stop the macro.

    We need to understand that the structure of the file is that each set of data is composed of 3 lines. Colum G to AC are ungrouped and colum A to F are group so it's the same value for each line.

    If user say yes to the above question, here's what I need :

    I want to copy data and paste it in the Historical Data sheet using this pattern :

    - First, I want to copy only the value that are different of ''-'' on the first line of my data set. (For example, in sheet Product 1, line 4, I will have 3 ungrouped column used (J-K-L)

    - I want to copy column A value into column A of the Historical Sheet (always on the next available line). This value will repeat for all 3 lines created by value in column J-K-L

    - I want to copy column B value into column B of the Historical Sheet. This value will repeat for all 3 lines created by value in column J-K-L

    - I want to copy column C value into column C of the Historical Sheet. This value will repeat for all 3 lines created by value in column J-K-L

    - I want to copy column D value into column D of the Historical Sheet. This value will repeat for all 3 lines created by value in column J-K-L

    - I want to copy column F value into column E of the Historical Sheet. This value will repeat for all 3 lines created by value in column J-K-L

    After that, I want :

    - In Historical Data column F, we bring back the value of line 3

    - In Historical Data column G, we bring back the value of line 4

    - In Historical Data column H, we bring back the value of line 5

    - In Historical Data column I, we bring back the value of line 6


    So the trigger is the date change in column F.

    We will alway bring line 3 in column F.

    The data for column G-H-I in Historical Data will vary depending on which date we change.


    I really hope this is clear enough for somebody to play with this.

    I've joined a copy of my file.

    Thanks in advance to all!
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,587

    Re: Excel macro of copy paste that transale both line and column into a single line

    Worksheet event is used for sheet Product1.
    Please Login or Register  to view this content.
    Same code should be copied to other required sheets.
    How to use worksheet event the code
    Right click on Sheet tab --> view code
    Visual Basic (VB) window opens.
    Paste the code
    Close the VB window.
    Save the file as .xlsm
    Attached Files Attached Files
    Pl note
    Array formula should be confirmed with Ctrl+Shift+Enter keys together.
    If answere is satisfactory press * to add reputation.

  3. #3
    Registered User
    Join Date
    03-13-2024
    Location
    Montreal, QC, Canada
    MS-Off Ver
    MS Office 365
    Posts
    2

    Re: Excel macro of copy paste that transale both line and column into a single line

    Hi, thanks so much.

    Some issue with the code.

    I add some info and they don't paste correctly in my Historical Data sheet

    Looks like they only check for info in column J to L. If I have info different then '-' in column other J-K-L, they ignore it.

    Also, if I say no the initial question, they put the date back but don't quit the macro. Can't do anything.

  4. #4
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,587

    Re: Excel macro of copy paste that transale both line and column into a single line

    Not clear. Pl upload file with expected result and explain.

+ 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. [SOLVED] Display only the first line of multi-line and/or single line cell?
    By stefan.g in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 01-27-2024, 02:10 PM
  2. Excel Subtotal Line - Copy paste upper row to subtotal Line
    By ayyappan80 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-31-2020, 05:11 AM
  3. [SOLVED] Macro to Copy and Paste Specific Text in Column A on the last line with Text in Column B?
    By D2S in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-18-2017, 04:08 PM
  4. Easier way to copy and paste values into a single line?
    By baustonian8 in forum Excel General
    Replies: 10
    Last Post: 03-03-2015, 11:46 AM
  5. [SOLVED] Macro to copy and paste to the next available line.
    By dragonfly352758 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-13-2013, 09:47 PM
  6. [SOLVED] How to write copy past macro in a single line
    By nur2544 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-02-2013, 04:49 AM
  7. Replies: 0
    Last Post: 09-26-2012, 11:26 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