Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Les Les is offline
external usenet poster
 
Posts: 240
Default Look up number entered into text box and populate another with res

Hi all,

I have a sheet "Local Parts" of part numbers in column "A" and the part
description in column "B".
I have a user form "frm_InputTM" with a text box "txt_PrtNum" where the user
will enter the part number, i then want to look up this number in the "Local
Parts" sheet and return the description and insert it in the text box
"txt_PrtDescription"

Could anybody please help me with this... thanks in advance...

--
Les
  #2   Report Post  
Posted to microsoft.public.excel.programming
Les Les is offline
external usenet poster
 
Posts: 240
Default Look up number entered into text box and populate another with res

I have this code, but it is not working ??

Txt_PrtDescription.Value = Excel.WorksheetFunction.VLookup(txt_PrtNum.Value,
Sheets("Local Parts").Range("A2:B65536"), 2, False)

Gratefull for any help....


--
Les


"Les" wrote:

Hi all,

I have a sheet "Local Parts" of part numbers in column "A" and the part
description in column "B".
I have a user form "frm_InputTM" with a text box "txt_PrtNum" where the user
will enter the part number, i then want to look up this number in the "Local
Parts" sheet and return the description and insert it in the text box
"txt_PrtDescription"

Could anybody please help me with this... thanks in advance...

--
Les

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 897
Default Look up number entered into text box and populate another withres

Why not read the part numbers and part descriptions into a two
dimensional array in the Userform_Initialize Event.

Dim arrData() As Variant
Dim ColACount As Long
Dim i As Long

ColACount = Range(Range("A1"), Range("A" &
Rows.Count).End(xlUp)).Count

ReDim arrData(1 To ColACount, 1 To 2)

For i = 1 To ColACount
arrData(i, 1) = Range("A" & i).Value
arrData(i, 2) = Range("B" & i).Value
Next i

Now you can look up the part number from txt_PrtNum in the array, and
wherever you find it, you know that the next column over is the data
you want.

For example if the part number was 12345 and it was stored in
arrData(10,1), then you simply return arrData(10,2) (assuming you did
set up your data table correctly)

HTH,
JP


On Sep 4, 10:44*pm, Les wrote:
Hi all,

I have a sheet "Local Parts" of part numbers in column "A" and the part
description in column "B".
I have a user form "frm_InputTM" with a text box "txt_PrtNum" where the user
will enter the part number, i then want to look up this number in the "Local
Parts" sheet and return the description and insert it in the text box
"txt_PrtDescription"

Could anybody please help me with this... thanks in advance...

--
Les


  #4   Report Post  
Posted to microsoft.public.excel.programming
Les Les is offline
external usenet poster
 
Posts: 240
Default Look up number entered into text box and populate another with

Thanks JP, much appreciated...
--
Les


"JP" wrote:

Why not read the part numbers and part descriptions into a two
dimensional array in the Userform_Initialize Event.

Dim arrData() As Variant
Dim ColACount As Long
Dim i As Long

ColACount = Range(Range("A1"), Range("A" &
Rows.Count).End(xlUp)).Count

ReDim arrData(1 To ColACount, 1 To 2)

For i = 1 To ColACount
arrData(i, 1) = Range("A" & i).Value
arrData(i, 2) = Range("B" & i).Value
Next i

Now you can look up the part number from txt_PrtNum in the array, and
wherever you find it, you know that the next column over is the data
you want.

For example if the part number was 12345 and it was stored in
arrData(10,1), then you simply return arrData(10,2) (assuming you did
set up your data table correctly)

HTH,
JP


On Sep 4, 10:44 pm, Les wrote:
Hi all,

I have a sheet "Local Parts" of part numbers in column "A" and the part
description in column "B".
I have a user form "frm_InputTM" with a text box "txt_PrtNum" where the user
will enter the part number, i then want to look up this number in the "Local
Parts" sheet and return the description and insert it in the text box
"txt_PrtDescription"

Could anybody please help me with this... thanks in advance...

--
Les



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Populate year, month and quarter from entered date Vic Excel Discussion (Misc queries) 2 May 7th 09 09:49 PM
Need to display a number when a specific text is entered Desperate Excel Discussion (Misc queries) 3 December 31st 07 05:03 AM
how can i re-populate a userform with data already entered? Paul Dye New Users to Excel 1 January 24th 07 04:49 AM
How do I get data entered in sheet1 to auto populate sheet2? MikeM Excel Programming 3 May 16th 06 01:51 AM
Entered text value equals a number I specify in another cell Dave S. Excel Worksheet Functions 3 June 12th 05 10:07 PM


All times are GMT +1. The time now is 10:39 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"