ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   variable not set (https://www.excelbanter.com/excel-programming/426390-variable-not-set.html)

RaulDR

variable not set
 
Hi all,

I have this, it returns the error "variable not set"

Dim sSearch As String

sSearch = InputBox("Enter String to Search", "Search")

Application.Cells.Find(What:=sSearch, After:=ActiveCell,
LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:= _
False, SearchFormat:=False).Activate


thanks so much in advance!

Mike H

variable not set
 
Hi,

There's nothing wrong with that snippet of code, your problem must lie in
another part. Post all the code.

Mike

"RaulDR" wrote:

Hi all,

I have this, it returns the error "variable not set"

Dim sSearch As String

sSearch = InputBox("Enter String to Search", "Search")

Application.Cells.Find(What:=sSearch, After:=ActiveCell,
LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:= _
False, SearchFormat:=False).Activate


thanks so much in advance!


Jacob Skaria

variable not set
 
You search string may be missing. Try this

Sub Mac()

Dim rngTemp As Range
Dim sSearch As String

sSearch = InputBox("Enter String to Search", "Search")

On Error Resume Next
Set rngTemp = Application.Cells.Find(What:=sSearch,
After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:= _
False, SearchFormat:=False)

On Error GoTo 0
If Not rngTemp Is Nothing Then Application.Goto rngTemp, True

End Sub

If this post helps click Yes
---------------
Jacob Skaria


"RaulDR" wrote:

Hi all,

I have this, it returns the error "variable not set"

Dim sSearch As String

sSearch = InputBox("Enter String to Search", "Search")

Application.Cells.Find(What:=sSearch, After:=ActiveCell,
LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:= _
False, SearchFormat:=False).Activate


thanks so much in advance!


Bony Pony[_2_]

variable not set
 
Is it perhaps that Option Explicit is set and you have incorrectly delcared
the variable? Or not at all?

"RaulDR" wrote:

Hi all,

I have this, it returns the error "variable not set"

Dim sSearch As String

sSearch = InputBox("Enter String to Search", "Search")

Application.Cells.Find(What:=sSearch, After:=ActiveCell,
LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:= _
False, SearchFormat:=False).Activate


thanks so much in advance!



All times are GMT +1. The time now is 01:55 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com