Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Looking up values in another file

Hi All

I am new to VBE and would appreciate help with the following if you can:

I need to link two files. File 1 has a link number and two values, lets
called then A and B.

File 2 has a list of values and if they match the link number in File 1 I
want values A and B inserted in specific columns in File 2.

Sounds easy, but I am having real trouble getting anything written.

I would like to get the function to run when a new value is entered in the
Value column in File 2, but I am lost.

Hope somebody has had the same problem and might have a solution.

Tim


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Looking up values in another file

You would use change event code to trap the change.

You also need to have the File2 open, and need to save it to a specific
cell. You don't say what and where you lookin g at, or where A & B are.

This is an example of trapping the change

Private Sub Worksheet_Change(ByVal Target As Range)

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range("A1:H10")) Is Nothing Then
With Target
'do something
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub

'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.

Give more details of th erest to work out how to apply.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Tim Patton" wrote in message
...
Hi All

I am new to VBE and would appreciate help with the following if you can:

I need to link two files. File 1 has a link number and two values, lets
called then A and B.

File 2 has a list of values and if they match the link number in File 1 I
want values A and B inserted in specific columns in File 2.

Sounds easy, but I am having real trouble getting anything written.

I would like to get the function to run when a new value is entered in the
Value column in File 2, but I am lost.

Hope somebody has had the same problem and might have a solution.

Tim




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Looking up values in another file

File 1 ( The lookup file ) has three columns:

Column A: "Profile Number" with entries 1 to 1500
Column B: "Passes" with values 1 or 2
Column C: "Speed" with values 55, 60 or 40

So in File 2 ( the entry file ) A "profile number" is entered in column
A, I then want the prog to open File 1, match the profile numbers and
then copy the corresponding values in columns B and C to Columns E and F
in File 2.

Thanks for helping me out Bob...

Hope this provides a bit more detail.

Cheers mate

Tim



*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Looking up values in another file

Tim,

Try this. I haven't tested it but hopefully it works. It assumes that the
value to be looked up is also in column A in file 1

Private Sub Worksheet_Change(ByVal Target As Range)
Dim oWb As Workbook
Dim oCell As Range

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range("A1")) Is Nothing Then
Set oWb = Workbooks.Open(Filename:="c:\test\file1.xls")
With oWb
On Error Resume Next
Set oCell = .Worksheets("Sheet1").Cells.Find(Target.Value)
If Not oCell Is Nothing Then
oCell.Offset(0.4).Value = Target.Offset(0, 1).Value
oCell.Offset(0.5).Value = Target.Offset(0, 2).Value
Else
MsgBox "Not found"
End If
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Tim Patton" wrote in message
...
File 1 ( The lookup file ) has three columns:

Column A: "Profile Number" with entries 1 to 1500
Column B: "Passes" with values 1 or 2
Column C: "Speed" with values 55, 60 or 40

So in File 2 ( the entry file ) A "profile number" is entered in column
A, I then want the prog to open File 1, match the profile numbers and
then copy the corresponding values in columns B and C to Columns E and F
in File 2.

Thanks for helping me out Bob...

Hope this provides a bit more detail.

Cheers mate

Tim



*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Looking up values in another file

File 1 ( The lookup file ) has three columns:

Column A: "Profile Number" with entries 1 to 1500
Column B: "Passes" with values 1 or 2
Column C: "Speed" with values 55, 60 or 40

So in File 2 ( the entry file ) A "profile number" is entered in column
A, I then want the prog to open File 1, match the profile numbers and
then copy the corresponding values in columns B and C to Columns E and F
in File 2.

Thanks for helping me out Bob...

Hope this provides a bit more detail.

Cheers mate

Tim



*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


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
How to tell number of spaces between values in saved text file fromthe original xls file [email protected] Excel Discussion (Misc queries) 1 January 15th 08 11:52 AM
How do I convert an excel file into a comma separated values file Conquerer Excel Discussion (Misc queries) 3 August 17th 06 09:19 PM
Pull values from each .xls file in dir Duke17 Excel Discussion (Misc queries) 4 May 28th 06 03:23 PM
Copy values from file A, Find/Replace these values in File B shockley Excel Programming 1 September 22nd 03 12:32 AM
Macro to insert values from a file and save another sheet as a .txt file Frank[_16_] Excel Programming 2 August 28th 03 01:07 AM


All times are GMT +1. The time now is 05:46 PM.

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"