5

The equivalent in c# would be this :

string s = MyFonction(s /* .Replace("r","t") */ );

I am commenting only a part of the line, this way I can't forget the little add up I made, and I can reactivate it by removing /* and */

I would like to do the same in Excel's VBA :

ActiveCell'.Offset(1, 0)'.CurrentRegion.Select

I don't think there is a way to do this directly. Still, it would be extremely useful to be able to comment parts of the line...

Is there a way to at least simulate it ?

Community
  • 1
  • 1
Antoine Pelletier
  • 2,764
  • 2
  • 30
  • 51
  • At first I was tempted to mark this as a duplicate of https://stackoverflow.com/q/24001501/1132334, which is itself a duplicate :) but your question is different. short answer: no. – Cee McSharpface Feb 15 '18 at 16:46
  • 3
    I would just comment the entire line & put the modified line directly below it - you could then just swap which line is commented to restore the extra bit. – PaulF Feb 15 '18 at 16:46
  • @PaulF It seems like a good way to go, thanks for the idea – Antoine Pelletier Feb 15 '18 at 17:47

1 Answers1

6

Not in VBA, you have to comment all the line

  • 2
    As far as I know, all VB flavors do not support this; not just VBA. It doesn't necessarily have to be the whole line. You can do it anywhere in the line, but there's no short terminating the comment. – TyCobb Feb 15 '18 at 16:49
  • You can add a comment to the end of a line without commenting it all. Note that this is not really an answer but more of a comment. – PaulF Feb 15 '18 at 16:53
  • there are some VB/VBA syntax rules around commenting (line continuation inside comment, starting comment with `REM`, "empty" comments) but none of them do what OP wants – Cee McSharpface Feb 15 '18 at 16:54
  • in fact, it can be the whole line, OR the rest of the line – Antoine Pelletier Feb 15 '18 at 17:50