#1   Report Post  
vishu
 
Posts: n/a
Default Solution please

I am very good in VLOOKUP().
I dont want to use and dont want to show formulas in my excel sheet
report. The form which I am creating is multi user form.
The person using this form is not aware of employee number. If he enter
employee name, he should automatically get corresponding employee number.
This form keep on passing to different person.

Is it possible create this form?? Please help me if any body has solutions
???macro???

  #2   Report Post  
Bob Phillips
 
Posts: n/a
Default

If you have a table of names and numbers on say sheet3 you could use this

Private Sub Worksheet_Change(ByVal Target As Range)

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range("H1:H10")) Is Nothing Then
With Target
.Offset(0, 1).Value = Application.VLookup(.Value,
Worksheets("Sheet3").Range("A1:B1000"), 2, False)
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.

--
HTH

Bob Phillips

"vishu" wrote in message
...
I am very good in VLOOKUP().
I don't want to use and don't want to show formulas in my excel sheet
report. The form which I am creating is multi user form.
The person using this form is not aware of employee number. If he enter
employee name, he should automatically get corresponding employee number.
This form keep on passing to different person.

Is it possible create this form?? Please help me if any body has solutions
???macro???



  #3   Report Post  
Max
 
Posts: n/a
Default

Hi Bob,

How could the #N/As which might appear in I1:I10 be averted via a tweak in
your code ? For e.g.: when entries made in H1:H10 are cleared, or for any
unmatched entries. ( I wanna leave no trace <g)

Thanks
--
Rgds
Max
xl 97
---
GMT+8, 1° 22' N 103° 45' E
xdemechanik <atyahoo<dotcom
----


  #4   Report Post  
Bob Phillips
 
Posts: n/a
Default

Hi Max,

By using Application.VLOOKUP, it is easy to trap the error

Private Sub Worksheet_Change(ByVal Target As Range)
Dim thisValue
On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range("H1:H10")) Is Nothing Then
With Target
thisValue = Application.VLookup(.Value,
Worksheets("Sheet3").Range("A1:B1000"), 2, False)
If Not IsError(thisValue) Then
.Offset(0, 1).Value = thisValue
End If
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub


Regards

Bob

"Max" wrote in message
...
Hi Bob,

How could the #N/As which might appear in I1:I10 be averted via a tweak in
your code ? For e.g.: when entries made in H1:H10 are cleared, or for any
unmatched entries. ( I wanna leave no trace <g)

Thanks
--
Rgds
Max
xl 97
---
GMT+8, 1° 22' N 103° 45' E
xdemechanik <atyahoo<dotcom
----




  #5   Report Post  
Max
 
Posts: n/a
Default

Thanks, Bob. But when I clear any input cell(s) within H1:H10, I would
probably want the corresponding displays in I1:I10, i.e. the previous
result(s), if any, to be cleared as well. How could this be achieved ?
--
Rgds
Max
xl 97
---
GMT+8, 1° 22' N 103° 45' E
xdemechanik <atyahoo<dotcom
----




  #6   Report Post  
Bob Phillips
 
Posts: n/a
Default

Hi Max,

Untetsed but should be okay

Private Sub Worksheet_Change(ByVal Target As Range)
Dim thisValue
On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range("H1:H10")) Is Nothing Then
With Target
thisValue = Application.VLookup(.Value, _
Worksheets("Sheet3").Range("A1:B1000"), 2, False)
If Not IsError(thisValue) Then
.Offset(0, 1).Value = thisValue
ElseIf Trim(.Value) = "" Then
.Offset(0,1).Value = ""
End If
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub


--
HTH

Bob Phillips

"Max" wrote in message
...
Thanks, Bob. But when I clear any input cell(s) within H1:H10, I would
probably want the corresponding displays in I1:I10, i.e. the previous
result(s), if any, to be cleared as well. How could this be achieved ?
--
Rgds
Max
xl 97
---
GMT+8, 1° 22' N 103° 45' E
xdemechanik <atyahoo<dotcom
----




  #8   Report Post  
Max
 
Posts: n/a
Default

Here's a sample file*:
http://flypicture.com/p.cfm?id=46111
(right-click on link "Download File" at the top)

File: BobP_sub_Vishu_misc.xls
*contains Bob's revised sub (v2)
--
Rgds
Max
xl 97
---
GMT+8, 1° 22' N 103° 45' E
xdemechanik <atyahoo<dotcom
----


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
Nested Subtotals in Excel 2003 -Solution GantryG Excel Discussion (Misc queries) 1 March 23rd 05 01:04 AM
How to deploy an Excel 2003 solution Mike Gartner Excel Discussion (Misc queries) 2 March 10th 05 01:29 AM
Generating excel combinations mark4006 Excel Discussion (Misc queries) 2 March 6th 05 04:40 PM
Benefits of using excel as a proramming solution Mark Green Excel Discussion (Misc queries) 2 February 2nd 05 08:04 PM
What is Multiple R, it is the first solution obtained in Regressi. Souvik Excel Worksheet Functions 1 November 28th 04 06:47 PM


All times are GMT +1. The time now is 10:54 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"