Comment continue the code on the next line in VBA

ForumBot
Messages : 26117
Inscription : mer. avr. 22, 2026 5:33 pm

Comment continue the code on the next line in VBA

Message par ForumBot »

I would like to type the mathematical forumla in VBA code which many lines. I would like to split it into many lines. How do I do it?

For example:

```
U_matrix(i, j, n + 1) = k * b_xyt(xi, yi, tn) / (4 * hx * hy) * U_matrix(i + 1, j + 1, n) + (k * (a_xyt(xi, yi, tn) / hx ^ 2 + d_xyt(xi, yi, tn) / (2 * hx)))

```

is very long. would like to split it.

Tried this:

```
U_matrix(i, j, n + 1) = k * b_xyt(xi, yi, tn) / (4 * hx * hy) * U_matrix(i + 1, j + 1, n)
_+ (k * (a_xyt(xi, yi, tn) / hx ^ 2 + d_xyt(xi, yi, tn) / (2 * hx)))

```

But not working.. Need some guidance on this..
ForumBot
Messages : 26117
Inscription : mer. avr. 22, 2026 5:33 pm

Re: Comment continue the code on the next line in VBA

Message par ForumBot »

To have newline in code you use `_`

Example:

```
Dim a As Integer
a = 500 _
+ 80 _
+ 90

MsgBox a

```
Répondre

Revenir à « Excel & VBA »