VLOOKUP Trouble w/ data from Multiline Textbox

szymagic

Board Regular
Joined
Jul 8, 2016
Messages
61
So I need some help with some VBA code. I am pretty much brand new to VBA, let alone coding, and you fine people of MrExcel have been my saviors over the past week.

The goal of my macro is to grab a variable amount of ID numbers (anywhere from 1 – 30) and to paste them in a column of another worksheet that is tied to a bunch of VLOOKUP formulas. My problem comes from the fact that when the IDs are posted in this column the Vlookup function doesn’t work. I have a feeling there is a carriage return, or something of that nature, attached to these numbers (using Ctrl + F and then Ctrl + J or Alt 0010 did not return anything). The IDs that this macro is grabbing come from a userform multiline textbox that the user pastes IDs into, then those IDs are pasted into the next available row and then split from one cell into several. The code for the userform I have is a little messy, but is as follows:

Code:
Private Sub ok_Click()

Range("'Report'!AL85").Select
ActiveCell.End(xlToRight).Select
lastcolumn = ActiveCell.Column
Cells(85, lastcolumn + 1) = txtpdp.Value
ActiveCell.End(xlToRight).Select

'Code found on Internet
    Dim Str As String, a
    Dim cnt As Integer
    Dim w()

             
    Str = txtpdp.Value
    a = Chr(10)
    cnt = UBound(Split(Str, a))
     
    ReDim w(1 To cnt + 1, 1 To 1)
     
    For i = 0 To cnt
        w(i + 1, 1) = Split(Str, Chr(10))(i)
    Next i
    'ActiveSheet.Range("AO85").Resize(i, 1) = w
    Worksheets("Report").Activate
    ActiveSheet.Range("AN85").End(xlToRight).Resize(i, 1) = w
    
Worksheets("Data Addition").Activate

    
Unload Me

End Sub


Thank you for any help or guidance on this issue! Sorry if it is a little difficult to understand what is going on, please feel free to ask any clarifying questions! Thanks again!
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
So I need some help with some VBA code. I am pretty much brand new to VBA, let alone coding, and you fine people of MrExcel have been my saviors over the past week.

The goal of my macro is to grab a variable amount of ID numbers (anywhere from 1 – 30) and to paste them in a column of another worksheet that is tied to a bunch of VLOOKUP formulas. My problem comes from the fact that when the IDs are posted in this column the Vlookup function doesn’t work. I have a feeling there is a carriage return, or something of that nature, attached to these numbers (using Ctrl + F and then Ctrl + J or Alt 0010 did not return anything). The IDs that this macro is grabbing come from a userform multiline textbox that the user pastes IDs into, then those IDs are pasted into the next available row and then split from one cell into several. The code for the userform I have is a little messy, but is as follows:

Code:
Private Sub ok_Click()

Range("'Report'!AL85").Select
ActiveCell.End(xlToRight).Select
lastcolumn = ActiveCell.Column
Cells(85, lastcolumn + 1) = txtpdp.Value
ActiveCell.End(xlToRight).Select

'Code found on Internet
    Dim Str As String, a
    Dim cnt As Integer
    Dim w()

             
    Str = txtpdp.Value
    a = Chr(10)
    cnt = UBound(Split(Str, a))
     
    ReDim w(1 To cnt + 1, 1 To 1)
     
    For i = 0 To cnt
        w(i + 1, 1) = Split(Str, Chr(10))(i)
    Next i
    'ActiveSheet.Range("AO85").Resize(i, 1) = w
    Worksheets("Report").Activate
    ActiveSheet.Range("AN85").End(xlToRight).Resize(i, 1) = w
    
Worksheets("Data Addition").Activate

    
Unload Me

End Sub


Thank you for any help or guidance on this issue! Sorry if it is a little difficult to understand what is going on, please feel free to ask any clarifying questions! Thanks again!

vlookup only works on a range that is sorted ascending
 
Upvote 0
a gauntlet of clean() and then fixed() and value() works..

Thanks for the right direction!
 
Upvote 0

Forum statistics

Threads
1,214,975
Messages
6,122,538
Members
449,088
Latest member
RandomExceller01

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top