tricks of gurus

Thanks for the advice Aladin.

I forgot about index, that is much better than using indirect.
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
Dang. this thing just up & died. Aladin was one of the those that I was hoping would contribute here. Instead, he just poo-poos the other posters :(


Come on, throw us bone Aladin! A nice meaty one with lots of marrow. :LOL:
 
it's a pitty this one died so early: perhaps the reason was you tried to keep it alive to strongly

something very simple about VBA
when I have some code which has a part I want to "turn on" and "turn off" for testing, it's tedious to comment (out) a bunch of lines
putting them between a "trivial" If ... End If makes the job quickly done
Code:
Sub test()
'some codelines
    If True Then 'change to False when needed
    'test codelines to turn on and off
    End If
'some other codelines
End Sub
alternatively you can use
If 1 = 1 Then 'If 1 = 0 Then

voilà :)
Erik
 
re the dying - I'll move to the Lounge

re Aladin 'poo pooing' - I'd rather interpret it as terse advice re implications of using some 'non-standard techniques' that those unfamiliar with them should be aware of

re other odd / undocumented offerings:

1) forgive shameless plug for own post :) but - get.cell (& by implication other old xl4 marcos):

http://www.mrexcel.com/board2/viewtopic.php?t=21312

2) use of subtotal() to generate an array of filtered items in a list:

http://j-walk.com/ss/excel/eee/eee001.txt

...used, e.g, here:

http://www.mrexcel.com/board2/viewtopic.php?t=42085&highlight=subtotal

...see also the other EE letters for further 'power formula techniques'

3) arrayed use of frequency() to work with 'runs' in data - an example from Domenic:

http://www.mrexcel.com/board2/viewtopic.php?t=244297&highlight=frequency
 
A common, but not always obvious to novice or intermediate users, use a LOOKUP function or the INDEX/MATCH combination to return a value from a range of values instead of nested IF statements.

As well, use the INDEX/MATCH combination to look across columns, down rows or both. Common knowledge to most on this board, but still a good one for novice and intermediate users.

Not necessarily a function, but formulas entered as NAMES are automatically array entered.

And of course don't forget about the (mostly) undocumented DATEDIF...
 
Very interesting links, Paddy.

I particularly like Domenic's FREQUENCY formula, I can just never quite remember how that works when I want to do it. :cry:

I've just been playing with some SUBTOTAL/OFFSET constructions myself to return a list of names according to values shown in another column like this:
subtotal_offset.xls
ABCD
1namefrequencylist2
2barry5barry
3phil1barry
4steve3barry
5gavin0barry
6barry
7phil
8steve
9steve
10steve
11 
Sheet1


Formula in C2 copied down

=IF(ROW()-ROW(B$2)< SUM(B$2:B$5),LOOKUP(ROW()-ROW(B$2),SUBTOTAL(9,OFFSET(B$1,,,ROW(B$2:B$5)-ROW(B$2)+1,)),A$2:A$5),"")

I was asked to produce something like this in the past but couldn't do so without a helper column. The SUBTOTAL/OFFSET part is crucial because it allows you an array of ranges, each range one cell greater than the next.

Finally, I like to think that my own "specialist subject" is dates and times and date and time-related formulas. I'm particularly keen on this simple formula which counts the number of Saturdays in a date range (between A1 and B1 inclusive)

=INT((WEEKDAY(A1)+B1-A1)/7)

and which can be adapted to count other days or as a NETWORKDAYS substitute (without the holidays)
 
Speaking of DATES, again, not undocumented, but still, in my opinion, not used to it's potential:-

=DATE(2006,1,0)

which returns the last day of the previous month specified. I've used this one rather creativly to solve some interesting problems.
 
In a similar vein....

=A1-DAY(A1)

a simple way to give the first day of the month of any date in A1.

I first saw this used here by Aladin (who else?)
 
In a similar vein....

=A1-DAY(A1)

a simple way to give the first day of the month of any date in A1.

I first saw this used here by Aladin (who else?)

Wouldn't that be

=A1-DAY(A1)+1

Barry?
 
it's a pitty this one died so early: perhaps the reason was you tried to keep it alive to strongly

something very simple about VBA
when I have some code which has a part I want to "turn on" and "turn off" for testing, it's tedious to comment (out) a bunch of lines
putting them between a "trivial" If ... End If makes the job quickly done
Code:
Sub test()
'some codelines
    If True Then 'change to False when needed
    'test codelines to turn on and off
    End If
'some other codelines
End Sub
alternatively you can use
If 1 = 1 Then 'If 1 = 0 Then

voilà :)
Erik

Surely, you would use conditional compilation?
 

Forum statistics

Threads
1,215,963
Messages
6,127,951
Members
449,412
Latest member
montand

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