0

I have been learning VBA for days I have a question in mind, is there a clever way to run something in which deletes all "select" keywords from a VBA code (assuming you don't deliberately use "select" in your code) The reason why I am asking is, as you know, going throw macro recorded code with a bunch of "select" statements can be distracting. Thanks in advance.

  • Is Replace from the Edit menu an option? Something like, replace select, or select. with an empty string. – njc Jul 22 '21 at 22:40
  • Be wary of what you remove. Recorded macros tend to rely on whatever is selected. – SnowGroomer Jul 22 '21 at 22:44
  • @njc Oh replace is a new thing for me. I like its idea but it seems the issue is you can only replace the word you typed. What I optimally want, is to replace the whole line that contain this keyword. – Hussain Alqahtani Jul 22 '21 at 22:47
  • 1
    You are a confused person. In VBA select refers to the Select case structure. What you are referring to is the Select method from Office objects. What you need to be aware of is that recording macros is ( mostly) ok for finding out how to operate on Office objects but to write good code you need to translate select oriented operations into range based operations. – freeflow Jul 22 '21 at 22:49
  • @SnowGroomer Oh no I am dumb I just realized this what you said, macros doesn't use the range object to run methods or properties, instead they use "selection". This is frustrating ... – Hussain Alqahtani Jul 22 '21 at 22:50
  • @freeflow you are right, I just realized that now – Hussain Alqahtani Jul 22 '21 at 22:51
  • @HussainAlqahtani .. For reference - [How to avoid using Select in Excel VBA](https://stackoverflow.com/questions/10714251/how-to-avoid-using-select-in-excel-vba?rq=1) – Naresh Jul 23 '21 at 01:43
  • Export modules and run regex against them then re-import. – QHarr Jul 23 '21 at 01:59
  • Hi, Just paste your code into free application Notepad++ or any other Txt editor and with Ctlr+F ".Select" with "" :) – p77u77n77k Jul 23 '21 at 08:54

0 Answers0