JohnKauffman
New Member
- Joined
- Nov 1, 2012
- Messages
- 36
When using a function within my code I can not figure out the logic of when to use WorksheetFunction and when not.
As test shows below, Sum() needs WorksheetFunction but ABS() fails with WorksheetFunction.
I usually figure it out by trial and error, but would like to understand the logic. I get a clue from intellisense options.
Are there two "classes" or groups of functions
ActiveCell.Value = WorksheetFunction.Sum(1, 2) 'Works
ActiveCell.Value = Sum(1, 2) 'Fails
ActiveCell.Value = WorksheetFunction.Abs(-5) 'Fails
ActiveCell.Value = Abs(-5) 'Works
As test shows below, Sum() needs WorksheetFunction but ABS() fails with WorksheetFunction.
I usually figure it out by trial and error, but would like to understand the logic. I get a clue from intellisense options.
Are there two "classes" or groups of functions
ActiveCell.Value = WorksheetFunction.Sum(1, 2) 'Works
ActiveCell.Value = Sum(1, 2) 'Fails
ActiveCell.Value = WorksheetFunction.Abs(-5) 'Fails
ActiveCell.Value = Abs(-5) 'Works