Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 80
Default vlookup function in VBA code

Hi Everyone
At first I had a code like following
' TextBox2 = Application.VLookup(TextBox1.Value,
Sheet4.Range("staff"), 2)
but that one does not work. Instead I modified like follows

Private Sub CommandButton4_Click()
TextBox2 = Application.VLookup(Sheet4.Range("g4"),
Sheet4.Range("staff"), 2)
End Sub

Private Sub TextBox1_Change()
Sheet4.Range("G4") = TextBox1.Value
End Sub
in that case it worked well. But why my first code did not work?Any
idea?
Thanks for the help...
Have a good day
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,646
Default vlookup function in VBA code

Try with a sheet specification, e.g.
TextBox2 =
Application.VLookup(Activesheet.TextBox1.Value,She et4.Range("staff"), 2)

Regards,
Stefi

€ť ezt Ă*rta:

Hi Everyone
At first I had a code like following
' TextBox2 = Application.VLookup(TextBox1.Value,
Sheet4.Range("staff"), 2)
but that one does not work. Instead I modified like follows

Private Sub CommandButton4_Click()
TextBox2 = Application.VLookup(Sheet4.Range("g4"),
Sheet4.Range("staff"), 2)
End Sub

Private Sub TextBox1_Change()
Sheet4.Range("G4") = TextBox1.Value
End Sub
in that case it worked well. But why my first code did not work?Any
idea?
Thanks for the help...
Have a good day

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 80
Default vlookup function in VBA code

On Aug 5, 9:40*pm, Stefi wrote:
Try with a sheet specification, e.g.
TextBox2 =
Application.VLookup(Activesheet.TextBox1.Value,She et4.Range("staff"), 2)

Regards,
Stefi

” ezt írta:



Hi Everyone
At first I had a code like following
' TextBox2 = Application.VLookup(TextBox1.Value,
Sheet4.Range("staff"), 2)
but that one does not work. Instead I modified like follows


Private Sub CommandButton4_Click()
TextBox2 = Application.VLookup(Sheet4.Range("g4"),
Sheet4.Range("staff"), 2)
End Sub


Private Sub TextBox1_Change()
Sheet4.Range("G4") = TextBox1.Value
End Sub
in that case it worked well. But why my first code did not work?Any
idea?
Thanks for the help...
Have a good day- Hide quoted text -


- Show quoted text -


Sorry I forgot to mention those textbox are in the userform.
thanks for the reply
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
Combine VLOOKUP and IF function so #NA isn't returned as a value from VLOOKUP buffgirl71 Excel Discussion (Misc queries) 12 November 14th 06 11:36 PM
VBA Code to Return Text Embeded in the VLOOKUP Function Magnivy Excel Programming 10 March 30th 06 07:29 AM
how to use a VLOOKUP function in a VBA code? Sunil New Users to Excel 3 June 13th 05 09:27 AM
I want to use Vlookup function and AND function in a single formu. prakash Excel Worksheet Functions 3 January 25th 05 07:11 AM
Using the Vlookup Function in VB Code Juanfer Excel Programming 1 September 4th 03 11:10 PM


All times are GMT +1. The time now is 05:38 AM.

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

About Us

"It's about Microsoft Excel"