Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
IT,
I like to set the function's return value at the top if possible so that I'm sure what state the function starts out with. But you could do it either my way or Tom's way. Either way, you do need to set the function's value to something in any case. In my test, if you never set the function's return value, it just returns False. The difference between a sub and a function is really very simple. A function can return a value. A sub cannot. James "IT_roofer" wrote in message ... "Zone" wrote: IT, make newCell a Function so it can return a value to the calling routine. James Function newCell() as Boolean newCell=True <snip ElseIf curCell 45 Then MsgBox "No more line entries available." & _ Chr(13) & "Please combine your entries and resubmit." NewCell=False Exit For Else ActiveCell.Offset(1, 0).Select End If Next End Function Thanks Guys for the suggestions. I noticed Tom put "newCell = True" after the For loop and Zone/James put it ahead of the For loop. Do I have to declare newcell = True/False outside of the For loop at all? Tom: I added in an "Exit For" (in code below) to get it to stop cycling through the cells to cell L45. There's a locked cell @L46 and it generated an error about accessing locked cells. Otherwise your code worked perfect. Thanks! Zone/James: I still don't quite get the difference between a function and a sub, but i guess that's part of learning! Maybe you could shed some light? (code) If (whiteSpace.test(ActiveCell.value)) Then newCell = True Exit For '<======[ THIS ] |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Excel Data Validation/Lookup function does function correcty | Excel Worksheet Functions | |||
LINKEDRANGE function - a complement to the PULL function (for getting values from a closed workbook) | Excel Worksheet Functions | |||
Excel - User Defined Function Error: This function takes no argume | Excel Programming | |||
Need to open the Function Arguments window from VBA for a user defined function. | Excel Programming | |||
User-Defined Function pre-empting Built-in Function? How to undo???? | Excel Programming |