Logo 
Search:

MS Office Forum

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds

Trouble with automaic

  Asked By: Dora    Date: Jan 16    Category: MS Office    Views: 621
  

I have problem. i have some number at worksheet. And i
want lookup that's number to my macro with vba. This
is like function at worksheet ( Vlookup)

this code

Private Sub TextBox1_AfterUpdate()

Dim myrange As Range
Dim Mycol As Range
Set myrange = Worksheets("sheet1").Range("a1:b10")
Set Mycol = myrange.Columns([1], [2])
TextBox2.Value =
Application.WorksheetFunction.VLookup(TextBox1,
myrange, Mycol, [False])

End Sub

Share: 

 

1 Answer Found

 
Answer #1    Answered By: Opal Alexander     Answered On: Jan 16

Although you don't say what your problem  is, I'm guessing it's the
VLOOKUP line that's failing on you. The reason is that the third
argument needs a number  - not a range - just like the worksheet  formula.
So Mycol needs to be dimmed as an Integer and - as far as I can work out
from what you're doing - assigned the value of 2.

 
Didn't find what you were looking for? Find more on Trouble with automaic Or get search suggestion and latest updates.




Tagged: