Page 3 of 3 FirstFirst 123
Results 21 to 22 of 22

Thread: VBA Vlookup with cumulative results

  1. #21
    New Member
    Join Date
    Aug 2018
    Posts
    44
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Default Re: VBA Vlookup with cumulative results

    I have recreated the original example and the script works fine. It obviously doesn't like something about the data I'm trying to work with. Could it be because there are spaces, hyphens, forwards slashes etc within the part data (in column K Sheet1 and B sheet2?

  2. #22
    Board Regular Akuini's Avatar
    Join Date
    Feb 2016
    Location
    Indonesia
    Posts
    2,148
    Post Thanks / Like
    Mentioned
    43 Post(s)
    Tagged
    4 Thread(s)

    Default Re: VBA Vlookup with cumulative results

    Quote Originally Posted by Excel_Blonde View Post
    I have recreated the original example and the script works fine. It obviously doesn't like something about the data I'm trying to work with. Could it be because there are spaces, hyphens, forwards slashes etc within the part data (in column K Sheet1 and B sheet2?

    Maybe there are some trailing spaces. Try removing those space by running this macro:
    Code:
    Sub trimSpace()
    Dim rng As Range, vb
    Dim i As Long
    With Sheets("Sheet3")
    Set rng = .Range("B2:B" & .Cells(.Rows.Count, "B").End(xlUp).Row)
        vb = rng.Value
        For i = 1 To UBound(vb, 1)
            vb(i, 1) = Trim(vb(i, 1))
        Next
        rng.Value = vb
    End With
    
    With Sheets("Sheet2")
    Set rng = .Range("K2:K" & .Cells(.Rows.Count, "K").End(xlUp).Row)
        vb = rng.Value
        For i = 1 To UBound(vb, 1)
            vb(i, 1) = Trim(vb(i, 1))
        Next
        rng.Value = vb
    End With
    
    End Sub

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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