0

I'm trying to record a macro that will format the files I have such as filtering, sorting, fill, gridlines and removing hyperlinks to place that data into another file.

The macro was too large. I am wondering about two things.

  1. Can I record multiple small macros and do each part individually?
  2. Is there something else I can use to format my file and then place in into Excel?
Community
  • 1
  • 1
  • 3
    When recording macros, typically it generates way too much code if you plan on re-using (but it's a great starting point!). I recommend looking in to how to [avoid using `.Select`/`.Activate`](https://stackoverflow.com/questions/10714251/how-to-avoid-using-select-in-excel-vba), and also learning how to use loops, set dynamic ranges, etc. which will help you shorten the code. Also, if your code does a bunch of different things, look to splitting it in to multiple subroutines/functions, and perhaps passing values through to a sub/function. – BruceWayne Sep 25 '19 at 14:42
  • What are you using to record the macros? NotePad++ is feature rich and can run multiple macros. – Chris Catignani Sep 25 '19 at 14:44
  • im using excel. We have these files that are first off text files that need to be opened and then formatted into excel to prepare to put into a report. The other is already excel but has hyerlinks and formatting along with info we don't need, which needs filtered out to run the report. All of our divisions aren't on the same system yet unfortunately so this is part of the job for an unknown amount of time – Christopher J Rode Sep 25 '19 at 15:01

1 Answers1

1

Without getting too technical, you can record many macros and then create a new subroutine to run them sequentially like:

Sub MySumToRunMacros()
    Call Macro1
    Call Macro2
    Call Macro3
End Sub

When you run that subroutine it will first run macro1 and then macro2 and then macro3 and then exit.

What I would recommend though is that you learn how to format your workbook/files by writing the macro/vba yourself. Formatting is pretty easy to do through VBA and you can start with the code that you already generated.

JNevill
  • 46,980
  • 4
  • 38
  • 63