• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 292
  • Last Modified:

Selection.Find function and variable problem

i'm trying to finish this macro. the problem is that the varVal is not being recognized by the Selection.Find function. i stepped thru it and the assignment of the string in the varVal is there, but turns up empty in the call up in the Selection.Find.

WHAT AM I DOING WRONG?

thanks!

Sub Macro5()
'
    Dim varVal As String
   
    Sheets("ONE LIST 11-13-2004No Dup's").Select
    Range("B1").Select
    Selection.End(xlDown).Select
    ActiveCell.Offset(1, 0).Activate
    ActiveCell.Offset(0, -1).Activate
   
    varVal = ActiveCell

    Sheets("Export725").Select
    Columns("A:A").Select
   
    Selection.Find(What:=vaVal, After:=ActiveCell, LookIn:=xlValues, LookAt _
        :=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
        False, SearchFormat:=False).Activate
    ActiveCell.Offset(0, 2).Activate
   
    Range(ActiveCell, ActiveCell.Offset(0, 6)).Select
    Selection.Copy
    Sheets("ONE LIST 11-13-2004No Dup's").Select
    ActiveCell.Offset(0, 1).Activate
    ActiveSheet.Paste
   
End Sub
0
ironpen45
Asked:
ironpen45
1 Solution
 
ironpen45Author Commented:
btw, this is vba in an excel macro. tia!
0
 
pratap_rCommented:
umm... you missed the r in varval

    Selection.Find(What:=vaVal, After:=ActiveCell, LookIn:=xlValues, LookAt _
        :=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
        False, SearchFormat:=False).Activate
    ActiveCell.Offset(0, 2).Activate

your corrected Selection.Find

    Selection.Find(What:=varVal, After:=ActiveCell, LookIn:=xlValues, LookAt _
        :=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
        False, SearchFormat:=False).Activate
    ActiveCell.Offset(0, 2).Activate


hehe.. these things happen :-)

prevent these type of errors by using option explicit at the top of your vb file or in options

Have Fun!
Pratap
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now