Results 1 to 3 of 3

Thread: VBA VLOOKUP

  1. #1
    Bronze Lounger
    Join Date
    Sep 2007
    Posts
    1,203
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi,

    I am using:

    Code:
    For Each RngFind In y1	 
    	RngFind.Offset(0, -13).Value = Application.VLookup(Left(RngFind.Offset(0, -12), 6), y5, 2, False)
    	If IsError(RngFind.Offset(0, -13)) Then
    		RngFind.Offset(0, -13).ClearContents
    	ElseIf RngFind.Offset(0, -13) = 0 Then
    		RngFind.Offset(0, -13).ClearContents
    	End If
    Next RngFind
    Where both y1 and y5 are ranges.

    VLookup(Left(RngFind.Offset(0, -12), 6) <<<< How can I lookup the first 6 characters ignoring spaces ?? Or can I extract the first 6 characters first and then use that to VLookup ?? TIA.

    Or even....... If possible...... The first 6 numeric characters ignoring anything that is not numeric (including zeros)

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    To extract the first 6 characters excluding spaces, use

    Left(Replace(RngFind.Offset(0, -12), " ", ""), 6)

    For the other, you could loop through the characters of RngFind.Offset(0, -12) and inspect each of them in turn.

  3. #3
    Bronze Lounger
    Join Date
    Sep 2007
    Posts
    1,203
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks Hans, that meets the vast criteria, the other will probably be more hassle than it is worth as these would be very minimal. Cheers.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •