+ Reply to Thread
Results 1 to 7 of 7

Code for making New columns of Data in a new file (from the data Copied)

  1. #1
    Forum Contributor
    Join Date
    07-10-2022
    Location
    USA
    MS-Off Ver
    2021
    Posts
    190

    Code for making New columns of Data in a new file (from the data Copied)

    Hi,
    I have timestamps in column I from cell I2 onward. Dates in column I is in Ascending order. In cell I2, date is 02-Jan. This date continues until cell I10. I want that respective values of Range I2:I10 for date 02-Jan should be copied from columns B and C. Now this code should also generate a new Excel file and paste this copied value in cell A1. Since data copied by code had 2 columns so on pasting on newly created file in cell A1, these two columns will show up covering Column A and B.
    Same way after date 02-Jan the next date comes is 03-Jan. this date 03-Jan is in this range I11:I25. So, respective values of this range in column B and C should be copied. This copied data should be pasted in the generated file in cell D1. And so on.

    Another Example 27-Jan
    Now date 27-Jan covers this range in Column I I41:I53. This date also comes in column S in this range S2:S14. Now this code should copy respective values of Range I41:I53 and S2:S14.
    Respective values of Column I should be picked from Column B and C
    Respective values of Column S should be picked from Column L and M

    This copied data should be pasted in the generated file in cell G1.
    Same for other dates coming in column S.

    Name of the Excel file Generated by Code:
    In dates of Column I and S, month and year is same in all timestamps. So, it should pic month name and year from any cell let’s say I2. In this Case, Name should be in this way January 2022 of the newly generated file.

    (As data in columns I and S is already in ascending order, so code should pick first date and go only till it ends and then copy respective values. It should Not Search date value in all cell of Column I and S one by one. In this way it may create load on my CPU. This is a sample file. In actual file I have almost 1 million Rows in column I and 0.8 million Rows in column S)

    (Date format copied from source file should be exactly equal to the pasted in the newly generated file)

    I have attached the file from which data is to be copied (Named as Source File)
    And another file showing Expected Results (Named As January 2022)

    I am using Excel 2021

  2. #2
    Forum Expert WideBoyDixon's Avatar
    Join Date
    10-03-2016
    Location
    Sheffield, UK
    MS-Off Ver
    365
    Posts
    2,182

    Re: Code for making New columns of Data in a new file (from the data Copied)

    I wrote this which should do what you want. It might prompt if the target file already exists - you need to answer "Yes" to overwrite it else the macro will fail:

    Please Login or Register  to view this content.
    WBD
    Office 365 on Windows 11, looking for rep!

  3. #3
    Forum Contributor
    Join Date
    07-10-2022
    Location
    USA
    MS-Off Ver
    2021
    Posts
    190

    Re: Code for making New columns of Data in a new file (from the data Copied)

    Hi Sir WideBoyDixon,

    Thank you so much. It Worked Exactly like what i wanted. Thank you So Much for this code.

  4. #4
    Forum Contributor
    Join Date
    07-10-2022
    Location
    USA
    MS-Off Ver
    2021
    Posts
    190

    Re: Code for making New columns of Data in a new file (from the data Copied)

    Hi Sir,
    Hi Sir,
    Last edited by rexcel548562; 08-07-2022 at 08:23 AM.

  5. #5
    Forum Expert WideBoyDixon's Avatar
    Join Date
    10-03-2016
    Location
    Sheffield, UK
    MS-Off Ver
    365
    Posts
    2,182

    Re: Code for making New columns of Data in a new file (from the data Copied)

    Urrrgh. Try this instead then:

    Please Login or Register  to view this content.
    WBD

  6. #6
    Forum Contributor
    Join Date
    07-10-2022
    Location
    USA
    MS-Off Ver
    2021
    Posts
    190

    Re: Code for making New columns of Data in a new file (from the data Copied)

    Hi Sir WideBoyDixon,
    Last edited by rexcel548562; 08-07-2022 at 08:24 AM.

  7. #7
    Forum Contributor
    Join Date
    07-10-2022
    Location
    USA
    MS-Off Ver
    2021
    Posts
    190

    Re: Code for making New columns of Data in a new file (from the data Copied)

    Hi Sir WideBoyDixon,
    Last edited by rexcel548562; 08-07-2022 at 08:24 AM.

+ 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] VBA Amendment to split copied data across different columns
    By Spoonman667 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-22-2019, 08:11 AM
  2. [SOLVED] Help with Parsing data copied from a PDF into columns
    By Chriz in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-10-2017, 08:34 AM
  3. Paste copied data in rows not columns
    By dgibney in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-12-2016, 04:46 AM
  4. [SOLVED] Data Copied Excess in columns
    By sagar007 in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 09-28-2012, 04:27 AM
  5. Code to Close worksheet where data is being copied from
    By bherbert in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-20-2010, 12:19 PM
  6. [SOLVED] New data will not sort with existing data from copied file
    By Carolyn in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 01-05-2006, 10:15 AM
  7. format cells-copied data from the txt file
    By Eric in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 11-22-2005, 11:09 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