coding more neatly

bigdan

Well-known Member
Joined
Oct 5, 2009
Messages
846
Office Version
  1. 2013
Platform
  1. Windows
back when i was doing java code used to get sooo imbedded that we used to make opening and closing brackets on top of each other rather than in one line. eg in quotes (when I put spaces in they get taken out so ive used periods instead)

blah blah
{
...... method X
...... ...... {
...... ...... ...... print(hello)
...... ...... }
}




that's not the best example as ive forgotten all my java, but you get the point. now is there some kinda convention to do this with excel?

i wrote this statement =IF(AND(N12<>N11,N12<>N13),"PROBLEM","")

in this case its small so there's no real need to break it up, but if i were to, how would i do so? first thing is, how would i take the ending bracket to the next line? ive tried to do so, havent been able to.
would you put the condition in one line, the true alternative on the next, the false alternative on the third?
 
Last edited:

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
If this is for formulas on a worksheet you can use ALT+ENTER.

If it's code then you can use the continuation underspace as Jen suggests.
 
Upvote 0
yes its formulas on a worksheet. thanks guys.

@norie would you write it the same way as jen?
 
Upvote 0
I might do it a bit different but I think that's a kind of personal thing.

I suppose if you were following Java then the closest you could get would be the condition on one line, the if on the next line and then the else on the 3rd.

Though I'm not sure that would look so good.

=IF(AND(N12<>N11,N12<>N13),
"problem",
"")

PS If you are using a lot of nesting it might be worth checking the formula and seeing if it could be done in some other way.
 
Upvote 0

Forum statistics

Threads
1,224,521
Messages
6,179,291
Members
452,902
Latest member
Knuddeluff

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top