Error when adding "Optional" parameter to an existing procedure

ElBombay

Board Regular
Joined
Aug 3, 2005
Messages
196
Hello Board,

The procedure below has always worked, basically just to save a few keystrokes, and present cleaner code. I I tried to expand it today to start the search from the current location. I just added an optional 2nd parameter (bottom bloc) but I get a very vague "Expected =" error. Can someone help me resolve this? Thanks.

/*
'----------------------------------------------------------------------------
Sub Find_Text(cString)
'
' Find_Text Macro
' Macro recorded 9/11/2006
'

Application.ScreenUpdating = 0
Range("A1").Select
Cells.Find(What:=cString, After:=ActiveCell, _
LookIn:=xlFormulas, LookAt:=xlPart, _
SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False).Activate

End Sub
'----------------------------------------------------------------------------

*/

/*
'----------------------------------------------------------------------------
Sub Find_Text(cString, Optional cBegin As String)
'
' Find_Text Macro
' Macro recorded 9/11/2006
'
If cBegin Is Null Then cBegin= "A1"

Application.ScreenUpdating = 0
Range(cBegin).Select
Cells.Find(What:=cString, After:=ActiveCell, _
LookIn:=xlFormulas, LookAt:=xlPart, _
SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False).Activate

End Sub
'----------------------------------------------------------------------------

*/
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
Not clear what you are attempting to accomplish with cBegin. It appears that it must be either the null string, or a legitimate cell address.
Can you elaborate on what you want to accomplish with this optional argument?
 
Upvote 0
2 things: Is Null is a sql function (possibly only Access sql - don't know). Use IsNull(cBegin) - except it won't be Null, it will be an empty string.
I don't see what that sub will do - find something perhaps, but then do nothing with it?
 
Upvote 0

Forum statistics

Threads
1,214,954
Messages
6,122,462
Members
449,085
Latest member
ExcelError

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