+ Reply to Thread
Results 1 to 24 of 24

Need macro code to rearrange columns and to delete unwanted columns

  1. #1
    Forum Contributor
    Join Date
    06-12-2013
    Location
    india
    MS-Off Ver
    Office 365
    Posts
    163

    Need macro code to rearrange columns and to delete unwanted columns

    Hi Team,

    I need your help to get the simple macro to rearrange the columns using the data given in the attached file named "Raw data" and delete the unwanted columns.

    Columns should rearrange as per the column header which I have given in the file named "report" and insert one column after B column(Date Created) & P Column (Last Updated Date).

    Add the formula in C & Q column as I have given in the file named "report" and remove the formulas on both columns.

    Note - In the attached sample reports I have given only 4 rows, so I need to use this macro for more rows, so sometimes it will be more than 500 as well.

    Kindly check and assist me on this request.
    Attached Files Attached Files

  2. #2
    Forum Expert PaulM100's Avatar
    Join Date
    10-09-2017
    Location
    UK
    MS-Off Ver
    Office 365
    Posts
    2,108

    Re: Need macro code to rearrange columns and to delete unwanted columns

    I need your help to get the simple macro to rearrange the columns
    So what you've tried so far, cause I can't see a code inside your workbooks?
    Click the * to say thanks.

  3. #3
    Forum Contributor
    Join Date
    06-12-2013
    Location
    india
    MS-Off Ver
    Office 365
    Posts
    163

    Re: Need macro code to rearrange columns and to delete unwanted columns

    I am new to the macros, so I manually updated yhe reports. Kindly help me in creating the macro for my report.

  4. #4
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,517

    Re: Need macro code to rearrange columns and to delete unwanted columns

    For the file you attached.
    Please Login or Register  to view this content.

  5. #5
    Forum Expert dangelor's Avatar
    Join Date
    09-06-2011
    Location
    Indiana, USA
    MS-Off Ver
    365 Pro Plus
    Posts
    2,274

    Re: Need macro code to rearrange columns and to delete unwanted columns

    A different tact, using Advanced Filtering (assumes report worksheet only has headers and does not contain formula column headings)...
    Please Login or Register  to view this content.

  6. #6
    Forum Contributor
    Join Date
    06-12-2013
    Location
    india
    MS-Off Ver
    Office 365
    Posts
    163

    Re: Need macro code to rearrange columns and to delete unwanted columns

    Thank you very much for the code.

    I have one more request, I have attached 2 more reports named "Raw Data 1.xlsx" & "Consolidated report.xlsx".

    I need your help to get the simple macro to rearrange the columns using the data given in the attached file named "Raw data 1" and delete the unwanted columns.

    Columns should rearrange as per the column header which I have given in the file named "Consolidated report" and insert one column after B column(Date Created) & P Column (Last Updated Date).

    Add the formula in C & Q column as I have given in the file named "report" and remove the formulas on both columns.

    After the above steps, the data needs to split based on the Tenant code given in the S column by creating a new sheets (sheet name should be tenant code name) and delete the rows if the column D (Global Vendor) is having the below given names in each sheet, but in the consolidate report none of the rows should delete.

    AT&T WIRELESS DO NOT USE
    VERIZON WIRELESS
    AT&T MOBILITY
    T-MOBILE
    ROGERS WIRELESS
    TELUS MOBILITY
    T-MOBILE UNITED STATES


    Note - In the attached sample reports I have given only few rows, so I need to use this macro for more rows, so sometimes it will be more than 500 as well.

    Kindly check and assist me on this request.
    Attached Files Attached Files

  7. #7
    Forum Contributor
    Join Date
    06-12-2013
    Location
    india
    MS-Off Ver
    Office 365
    Posts
    163

    Re: Need macro code to rearrange columns and to delete unwanted columns

    Hi dangelor

    I am getting error using the macro code which you have given.

  8. #8
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,517

    Re: Need macro code to rearrange columns and to delete unwanted columns

    Consolidate Report workbook should have header as it is.
    Assuming both Raw Data 1.xlsx & Consolidate Report are saved in the same folder and Raw Data 1.xlsx MUST be closed if open.

    Run this from Consolidate Report workbook
    Please Login or Register  to view this content.
    Last edited by jindon; 08-02-2019 at 10:51 AM. Reason: Added one line

  9. #9
    Forum Contributor
    Join Date
    06-12-2013
    Location
    india
    MS-Off Ver
    Office 365
    Posts
    163

    Re: Need macro code to rearrange columns and to delete unwanted columns

    Hi Jindon,

    I have only one file named "Raw Data 1.xlsx", some times even the file name will change. Actually I need the code to run in Raw data 1.xlsx file and I need the report which is similar to the Consolidate Report workbook with the steps given above. Kindly check and assist me.

    Also the Wrap Text option should inactive in each sheet.

  10. #10
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,517

    Re: Need macro code to rearrange columns and to delete unwanted columns

    Then change to
    Please Login or Register  to view this content.

  11. #11
    Forum Contributor
    Join Date
    06-12-2013
    Location
    india
    MS-Off Ver
    Office 365
    Posts
    163

    Re: Need macro code to rearrange columns and to delete unwanted columns

    Hi Jindon,

    Thank you very much the code is working fine but it is running bit slow.

  12. #12
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,517

    Re: Need macro code to rearrange columns and to delete unwanted columns

    It would be slow when there are large amount of data in raw data.

    You could try set ScreenUpdating False and True e.g.
    Please Login or Register  to view this content.

  13. #13
    Forum Expert dangelor's Avatar
    Join Date
    09-06-2011
    Location
    Indiana, USA
    MS-Off Ver
    365 Pro Plus
    Posts
    2,274

    Re: Need macro code to rearrange columns and to delete unwanted columns

    Please Login or Register  to view this content.
    Code added to Consolidated file and saved as macro enabled.
    Attached Files Attached Files
    Last edited by dangelor; 08-03-2019 at 01:22 PM.

  14. #14
    Forum Contributor
    Join Date
    06-12-2013
    Location
    india
    MS-Off Ver
    Office 365
    Posts
    163

    Re: Need macro code to rearrange columns and to delete unwanted columns

    Hi Jindon,

    Thank you very much for your help, kindly assist me whether I need to add this screen updating code to the existing macro given below which you have given earlier or do I need to run the screen updating macro separately.

    Also I need one last help, the macro code which you have given below is to run on the active sheet, so is there any chance where I can create one button to add this macro and once I clicked the but it should ask for the raw file and once the raw file is selected the consolidated report should ready in a different file.

    Please Login or Register  to view this content.
    Last edited by Giri.hb; 08-05-2019 at 12:34 AM.

  15. #15
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,517

    Re: Need macro code to rearrange columns and to delete unwanted columns

    OK, thanks for the code tags.
    Please Login or Register  to view this content.
    Last edited by jindon; 08-05-2019 at 12:37 AM.

  16. #16
    Forum Contributor
    Join Date
    06-12-2013
    Location
    india
    MS-Off Ver
    Office 365
    Posts
    163

    Re: Need macro code to rearrange columns and to delete unwanted columns

    Thank you very much Jindon.

    As I requested earlier, please check and assist me on the below.

    Also I need one last help, the macro code which you have given below is to run on the active sheet, so is there any chance where I can create one button to add this macro and once I clicked the button it should ask for the raw file and once the raw file is selected the consolidated report should ready in a different file.

  17. #17
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,517

    Re: Need macro code to rearrange columns and to delete unwanted columns

    Not clear.

    All the reports should be created within the raw file or current workbook?

  18. #18
    Forum Contributor
    Join Date
    06-12-2013
    Location
    india
    MS-Off Ver
    Office 365
    Posts
    163
    Quote Originally Posted by jindon View Post
    Not clear.

    All the reports should be created within the raw file or current workbook?
    I need to create a macro button in one work book. Once I open that workbook and click on that button it should ask for the raw file. Once the raw file is selected, the above given macro should run and it should create consolidated report.

  19. #19
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,517

    Re: Need macro code to rearrange columns and to delete unwanted columns

    Reports to where?

    Raw data workbook? or the one you are calling the sub from?

  20. #20
    Forum Contributor
    Join Date
    06-12-2013
    Location
    india
    MS-Off Ver
    Office 365
    Posts
    163

    Re: Need macro code to rearrange columns and to delete unwanted columns

    Sorry for the confusion. Once the raw file is selected using the macro button, the above given macro should run and the consolidated report should come in new workbook.

    Currently the macro is running based on the column number to rearrange/delete the columns, instead can you please change that to column header name. So if I run the macro in any of the report, the column should rearrange/delete based on the column header name.

  21. #21
    Forum Contributor
    Join Date
    06-12-2013
    Location
    india
    MS-Off Ver
    Office 365
    Posts
    163

    Re: Need macro code to rearrange columns and to delete unwanted columns

    Please help me on the above request

  22. #22
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,517

    Re: Need macro code to rearrange columns and to delete unwanted columns

    How do you determine which columns should be left?

    Do you have a list for the heading somewhere in worksheet?

  23. #23
    Forum Contributor
    Join Date
    06-12-2013
    Location
    india
    MS-Off Ver
    Office 365
    Posts
    163

    Re: Need macro code to rearrange columns and to delete unwanted columns

    Hi Jindon,

    Thank you for checking, I have already provided the column header names what I need in the Consolidated report.xlsx‎ worksheet which I was provided earlier. Please don't do anything for now.
    I will send you the the updated report what I need and the details by tomorrow, so that you can assist me on this request, instead of working on the old report. Thank you very much for your help.

  24. #24
    Forum Guru
    Join Date
    04-23-2012
    Location
    New Jersey, USA
    MS-Off Ver
    Excel 365
    Posts
    2,408

    Re: Need macro code to rearrange columns and to delete unwanted columns

    It is late here (I'm about to got to sleep) and I might have missed something, but if I didn't and acknowledging that the OP asked for addition code afterwards which I am not addressing, then I think this non-looping macro will do what the codes posted in Messages #4 and #5 do (possibly even quicker)...
    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. [SOLVED] Delete unwanted columns and only keeping known name columns
    By robertguy in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 08-15-2018, 07:06 AM
  2. Replies: 4
    Last Post: 08-02-2018, 07:13 PM
  3. [SOLVED] A Macro to Delete Unwanted Columns
    By newbieexceldude in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-25-2016, 10:36 PM
  4. [SOLVED] VBA code to rearrange data into multiple columns
    By shinobi in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-14-2013, 06:33 AM
  5. Replies: 0
    Last Post: 08-02-2012, 10:46 PM
  6. Macro to loop through all sheets and delete unwanted columns
    By LemonTwist in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-24-2009, 12:03 PM
  7. Delete unwanted columns
    By stevekirk in forum Excel General
    Replies: 6
    Last Post: 09-24-2006, 08:52 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