starchildren3317
New Member
- Joined
- May 17, 2011
- Messages
- 6
I am getting a type mismatch error on a function that I created and can't figure out why. Perhaps one of you can find where I am going wrong.
First some background into what I am trying to do:
I have a workbook with four worksheets. The first one I have created a form to perform the certain tasks. The other three worksheets contain data.
I am trying to look in a worksheet for a value and then copy the entire row that contains that value into the first worksheet.
Here is a snip of what I have:
When I run this I get a type mismatch error starting on the bolded line of code above.
First some background into what I am trying to do:
I have a workbook with four worksheets. The first one I have created a form to perform the certain tasks. The other three worksheets contain data.
I am trying to look in a worksheet for a value and then copy the entire row that contains that value into the first worksheet.
Here is a snip of what I have:
Code:
Dim FindRange As Range
If chbSM.Value Then [COLOR=SeaGreen]'chbSM is the name of a checbox in my form.[/COLOR]
FindRange = FindValue("Sample Master") [COLOR=SeaGreen]'FindValue is my function, I am passing in a value to search for. [/COLOR]
With Worksheets(2).Range(FindRange)
.Range(.Cells(1), .End(xlToRight)).Copy Destination:=Worksheets("AppSelect").Range("A2")
End With
End If
[COLOR=SeaGreen]'Here is the function[/COLOR]
Function FindValue(FindWhat As String)
Dim FoundRange As Range
[B]Set FoundRange = Cells.Find(What:=FindWhat, After:=Range("A1").Activate, LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False)[/B]
End Function