+ Reply to Thread
Results 1 to 17 of 17

Macro to separate, concatenate, and change sheet names

  1. #1
    Registered User
    Join Date
    04-26-2014
    Location
    Germany
    MS-Off Ver
    Excel 2010
    Posts
    21

    Macro to separate, concatenate, and change sheet names

    I am brand new to Macros - in fact, I really do not know what I am doing with them at all.

    I would like to see if I can create a macro to even more simplify the repetitive tasks that I need to do. This will reference the Macro solution that was given to me in Post #4 on this link: http://www.excelforum.com/excel-gene...ml#post3679700

    I gave a simplified version of what I am actually trying to do because I didn't expect as awesome of an answer as I got - and, it seems, with using a Macro, I could get Excel to do even more for me.

    Here is a table of exactly what I am looking at


    SHEET 1
    A B C D E
    Date&Time Ask Price Bid Price Ask Volume Bid Volume
    2007.03.25 21:00:03.496 1.64845 1.64785 1 1
    That is the basic setup and it goes for about 500,000 rows and I have almost 5,500 workbooks. So the idea of automating my tasks as much as possible is extremely appealing

    Following the pattern on the link that I gave above, I would like the following:

    ASK (This is Sheet #2 having been renamed)
    A B
    20070325 210003;1.64845;1
    (concatenation of Time, Ask Price, & Ask Volume...all separated only by a ";")

    BID (Rename of Sheet 3)
    A B
    20070325 210003;1.64785;1
    (concatenation of Time, Bid Price, & Bid Volume...all separated only by a ";")

    And, with the answer, could you also share with me precisely how I am supposed to enter this Macro into excel and also if there is some way of being able to this in a batch, rather than each file individually?

    thank you very much and I deeply appreciate any help that anyone is able to give to me.
    Last edited by JGSmith; 05-01-2014 at 08:50 AM.

  2. #2
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Macro Help - Newbie

    Hi, JGSmith,

    Your post does not comply with Rule 1 of our Forum RULES. Your post title should accurately and concisely describe your problem, not your anticipated solution.

    Use terms appropriate to a Google search. Poor thread titles, like Please Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will be addressed according to the OP's experience in the forum: If you have less than 10 posts, expect (and respond to) a request to change your thread title. If you have 10 or more posts, expect your post to be locked, so you can start a new thread with an appropriate title.

    To change a Title on your post, click EDIT then Go Advanced and change your title, if 2 days have passed ask a moderator to do it for you.

    (This thread should receive no further responses until this moderation request is fulfilled, as per Forum Rule 7)

    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  3. #3
    Registered User
    Join Date
    04-26-2014
    Location
    Germany
    MS-Off Ver
    Excel 2010
    Posts
    21

    Re: Macro to separate, concatenate, and change sheet names

    Thank you Holger for helping me comply with the rules. Never was it my intention to do otherwise.

    If this now meets your criteria, then I would appreciate it if you would state so and then people could kindly help me acquire the information that I need.

    Thank you

  4. #4
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Macro to separate, concatenate, and change sheet names

    Hi, JGSmith,

    I´ll take the easy part first about inserting VBA code

    How to install your new code
    1. Copy the Excel VBA code
    2. Select the workbook in which you want to store the Excel VBA code
    3. Press Alt+F11 to open the Visual Basic Editor
    4. Choose Insert > Module
    5. Edit > Paste the macro into the module that appeared
    6. Close the VBEditor
    7. Save your workbook (Excel 2007+ select a macro-enabled file format, like *.xlsm)

    To run the Excel VBA code:
    1. Press Alt-F8 to open the macro list
    2. Select a macro in the list
    3. Click the Run button
    For the other question I would like to ask for a workbook with some samples instead of any pictures. The code could be placed in one workbook and all files could be opened, procesed and closed and saved without having to install the code there (this could be either a workbook or an AddIn).

    Ciao,
    Holger

  5. #5
    Registered User
    Join Date
    04-26-2014
    Location
    Germany
    MS-Off Ver
    Excel 2010
    Posts
    21

    Re: Macro to separate, concatenate, and change sheet names

    Oh that is great. Thanks and it definitely helps

    Here is are two sample files. One of them is showing the way that I would like this to ultimately look, and the other one is just stock version of the files that I have.
    Attached Files Attached Files

  6. #6
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Macro to separate, concatenate, and change sheet names

    Hi, JGSmith,

    this is only for the file you provided to run a test and see if things head into what you finally want.

    Please Login or Register  to view this content.
    Ciao,
    Holger

  7. #7
    Registered User
    Join Date
    04-26-2014
    Location
    Germany
    MS-Off Ver
    Excel 2010
    Posts
    21

    Re: Macro to separate, concatenate, and change sheet names

    Hi Holger

    Thank you very much for the work that you have put into this.

    Unfortunately, it is not working on my side.

    It looks as though I have gone through all of the steps that you have mentioned but, at this point, to no avail.

    There are two primary problems that it looks like I am having.

    1. I have gone through all of the steps of importing the macro. Then when I reopen the file and click ctr f8, it shows me the macro name. I click on that but it does not give me the option to run it. (the run button is greyed out).

    From that point I saved it the macro and restarted the file, which leads me to the second issue

    2. When I did ctr f8 again, this time I had Modul1 & Module 2 and both had the same file name associated with it. (Module1:EF1007981 & Module2:EF1007981). I clicked on Module 1 and clicked run. With that I received a Runtime error and the option to debug the code. I clicked on the second Module and clicked run and then the dialogue box disappeared but nothing happened to the workbook.

    I hope that is enough information to troubleshoot. Let me know if you need anything else.

    Thanks!!

  8. #8
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Macro to separate, concatenate, and change sheet names

    Hi, JGSmith,

    for me it´s ALT+F8 to go to the macro box.

    You should have only one macro of teh given name.

    Have a look at the attachment, where I placed a button to start the macro.

    Ciao,
    Holger
    Attached Files Attached Files

  9. #9
    Registered User
    Join Date
    04-26-2014
    Location
    Germany
    MS-Off Ver
    Excel 2010
    Posts
    21

    Re: Macro to separate, concatenate, and change sheet names

    Thanks.

    I am still running into an issue. Here is a screenshot of what happens when I click the Run Macro button
    Attached Images Attached Images

  10. #10
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Macro to separate, concatenate, and change sheet names

    Hi, JGSmith,

    you don´t have the path

    Please Login or Register  to view this content.
    on your computer - not so surprising.

    You would need to adapt the drive and folders as well as the name of the file to suit your requirements. You could use Application.GetOpenFilename or BrowseForFolder to get the information or place this information in cells on a worksheet but for the moment you should alter the information for the constants.

    Ciao,
    Holger

  11. #11
    Registered User
    Join Date
    04-26-2014
    Location
    Germany
    MS-Off Ver
    Excel 2010
    Posts
    21

    Re: Macro to separate, concatenate, and change sheet names

    Oh, haha. Thanks

    So I changed the file path to the correct one.

    Now when I clicked Run Macro, it opens up the file and then immediately closes the file with no changes.

  12. #12
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Macro to separate, concatenate, and change sheet names

    Hi, JGSmith,

    if I remember correctly any textfile will only consist of one sheet, so could you please explain to me how to add sheets to these files? Check the folder and see if any processed file has been saved there, maybe open that and have a glimpse at what this file may look like.

    Ciao,
    Holger

  13. #13
    Registered User
    Join Date
    04-26-2014
    Location
    Germany
    MS-Off Ver
    Excel 2010
    Posts
    21

    Re: Macro to separate, concatenate, and change sheet names

    ah yes. du hast recht (I see you are from Hamburg )

    These are CSV files which means they will not be able to add a second page. I had hoped that somehow I could avoid some extra work by having the macro create another page and save it as an excel sheet. That being said, it is not necessary as long as it will allow me to create the columns that I need. Then I can take that and copy it into a wordpad file.

    So if you could help me create this macro to simply take the columns that are going on the second and third tabs and put them on the first tab and save it, that would be really great.

  14. #14
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Macro to separate, concatenate, and change sheet names

    Hi, JGSmith,

    have a look at this:
    Please Login or Register  to view this content.
    Manipulation will take place on the same sheet, you could either leave empty columns between the areas or use a code to export the desired columns into textfiles.

    Ciao,
    Holger

  15. #15
    Registered User
    Join Date
    04-26-2014
    Location
    Germany
    MS-Off Ver
    Excel 2010
    Posts
    21

    Re: Macro to separate, concatenate, and change sheet names

    This gives me a compile error saying that the Sub or Function is not defined

    when I click OK, it takes me to the debugger and it has this highlighted: Sub Schaltfläche1_Klicken()

    That could be the difference between a German & English Excel, which I have seen cause problems before. (primarily in the functions - such as using wenn verses if, etc)

  16. #16
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Macro to separate, concatenate, and change sheet names

    Hi, JGSmith,

    if you pasted the new procedure over the existing one you would need to adapt the correct name in the calling procedure.

    Ciao,
    Holger

  17. #17
    Registered User
    Join Date
    04-26-2014
    Location
    Germany
    MS-Off Ver
    Excel 2010
    Posts
    21

    Re: Macro to separate, concatenate, and change sheet names

    Great thank you

    The only problem is that I am absolutely a complete beginner with this part of excel, and therefore I really do not know what you are saying. (sorry)

    What is the "correct name" and what is a calling procedure?

    Could you give me an example of exactly what I should be doing? This will hopefully reduce the amount of confusion.

    In the meantime, I am starting to do some basic reading on Macros in order to get myself fully up to speed on how to do this stuff.

+ 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. Newbie in Macro
    By Carbonlink in forum Hello..Introduce yourself
    Replies: 1
    Last Post: 01-20-2014, 07:45 PM
  2. [SOLVED] VBA Newbie needs some help with looping macro
    By CDNcameron in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-08-2012, 12:53 PM
  3. Need help with a Excel Macro (I am a Newbie)
    By theebookzoo in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-13-2008, 08:36 AM
  4. VBA newbie needs help with triggering a macro
    By mav93 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-24-2006, 02:15 PM
  5. Newbie - Help with a macro
    By Mike Basden in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-08-2006, 08:40 PM

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