Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default How do I break VBA code into two or more lines?

Using Excel 2003/Windows XP/VBA Editor 6.3.
I have some very long lines which don't fit in the VBA Editor window and to
make the code easier to read I want to break them into two or more lines.
I was told to type a space then and underscore but this doesn't work.
(I am not talking about breaking the lines in Message Boxes).
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,327
Default How do I break VBA code into two or more lines?

Of course it works.

If Day(Date) 10 _
And Hour(Time) 20 Then _
MsgBox "It is after the tenth " & _
"and it is evening"

HTH. Best wishes Harald

"Kasama" skrev i melding
...
Using Excel 2003/Windows XP/VBA Editor 6.3.
I have some very long lines which don't fit in the VBA Editor window and

to
make the code easier to read I want to break them into two or more lines.
I was told to type a space then and underscore but this doesn't work.
(I am not talking about breaking the lines in Message Boxes).



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 290
Default How do I break VBA code into two or more lines?

I think Kasama has probably tried to break inbetween words maybe?

only break after complete words, (as harolds example shows) for some
reason it gets confused otherwise!
Duncan


Harald Staff wrote:
Of course it works.

If Day(Date) 10 _
And Hour(Time) 20 Then _
MsgBox "It is after the tenth " & _
"and it is evening"

HTH. Best wishes Harald

"Kasama" skrev i melding
...
Using Excel 2003/Windows XP/VBA Editor 6.3.
I have some very long lines which don't fit in the VBA Editor window and

to
make the code easier to read I want to break them into two or more lines.
I was told to type a space then and underscore but this doesn't work.
(I am not talking about breaking the lines in Message Boxes).


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,440
Default How do I break VBA code into two or more lines?

<I was told to type a space then and underscore

and then press ENTER

--
Kind regards,

Niek Otten
Microsoft MVP - Excel

"Kasama" wrote in message ...
| Using Excel 2003/Windows XP/VBA Editor 6.3.
| I have some very long lines which don't fit in the VBA Editor window and to
| make the code easier to read I want to break them into two or more lines.
| I was told to type a space then and underscore but this doesn't work.
| (I am not talking about breaking the lines in Message Boxes).


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,327
Default How do I break VBA code into two or more lines?

"Niek Otten" skrev i melding
...
<I was told to type a space then and underscore

and then press ENTER

--
Kind regards,

Niek Otten
Microsoft MVP - Excel


Lol. That may be the problem, yes.
MVP! Really glad to hear that, Niek.

Best wishes Harald




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default How do I break VBA code into two or more lines?

Tks, but that wasn't it. After typing Space+Underscore+Enter I was getting
"Invalid Character" error messages for the underscore. So I tried copying and
pasting your code and Harald Staff's code into blank macros. This time VBE
accepted the underscores, and then broke the line when I typed ' _enter'. No
more error messages.
But then I noticed a strange thing: up till now VBE has automatically placed
a line of underscores between my Sub procedures -- if I typed 'Sub' on a new
line after
'End Sub' I a dividing line of underscores automatically appeared.
These have now disappeared from all existing macros!
So it seems to me as if 'underscore' was assigned to a dividing line, and
after pasting in your code, VBE has reassigned unserscore to 'line continues
on next'.

Thanks

Kasama

"Niek Otten" wrote:

<I was told to type a space then and underscore

and then press ENTER

--
Kind regards,

Niek Otten
Microsoft MVP - Excel

"Kasama" wrote in message ...
| Using Excel 2003/Windows XP/VBA Editor 6.3.
| I have some very long lines which don't fit in the VBA Editor window and to
| make the code easier to read I want to break them into two or more lines.
| I was told to type a space then and underscore but this doesn't work.
| (I am not talking about breaking the lines in Message Boxes).



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default How do I break VBA code into two or more lines?

Hi Kasama

Like this

Sub Mail_workbook_1()
ActiveWorkbook.SendMail ", _
"This is the Subject line"
End Sub


See the space between the , and the _



--
Regards Ron de Bruin
http://www.rondebruin.nl



"Kasama" wrote in message ...
Using Excel 2003/Windows XP/VBA Editor 6.3.
I have some very long lines which don't fit in the VBA Editor window and to
make the code easier to read I want to break them into two or more lines.
I was told to type a space then and underscore but this doesn't work.
(I am not talking about breaking the lines in Message Boxes).



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Page Break Lines in Excel 2007 Ostate Excel Discussion (Misc queries) 2 February 24th 07 04:48 PM
Break cell into multiple lines by line break Chia Excel Discussion (Misc queries) 1 August 20th 06 06:37 AM
Sort columns between break lines winstonsnyder Excel Discussion (Misc queries) 1 August 21st 05 06:58 PM
automatically put in page break after 14 lines. Steved Excel Programming 2 August 2nd 05 10:07 AM
Hatched page break lines Hotbird[_2_] Excel Programming 2 February 20th 04 02:36 PM


All times are GMT +1. The time now is 01:46 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"