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

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.

JoeMo

MrExcel MVP
Joined
May 26, 2009
Messages
17,963
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
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?
 

Micron

Well-known Member
Joined
Jun 3, 2015
Messages
3,781
Office Version
  1. 365
Platform
  1. Windows
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?
 

Forum statistics

Threads
1,176,123
Messages
5,901,515
Members
434,899
Latest member
powerappsjoker99

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
Top