#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3
Default Excel VBA vlookup

Hello

This is my first Excel VBA to publish in the forum and happy to join
the Excel VBA family.

Excel vlookup function is very useful in many applications.

I develop a VBA to make Vlookup run faster if you many rows to lookup
and more user friendly , please try the code.

I appreciate your comment.

Option Explicit

Dim finalrow As Integer
Dim Mysheet As String
Dim mycolumn As Long
Dim Myrange As String
Dim mycount As Long
Dim i As Integer
Dim mylookup As Variant
Dim mystring As String
Dim myvalue As Long

Sub Vlookup()

mycolumn = Application.InputBox("Please enter the lookup column
number", Type:=1)
myvalue = Application.InputBox("Please enter the column number you want
to place your lookup up result ", Type:=1)
Mysheet = InputBox("Please enter lookup worksheet name",
"WorksheetName", Default)
Myrange = InputBox("Please enter lookup range", "Range", Default)

mycount = Range(Myrange).Columns.Count

On Error Resume Next

Columns(myvalue).Insert Shift:=xlToRight

finalrow = Cells(65536, mycolumn).End(xlUp).Row

For i = 1 To finalrow

mystring = (Cells(i, mycolumn))

mylookup = Application.Vlookup((mystring),
Worksheets(Mysheet).Range(Myrange), mycount, False)

Cells(i, myvalue).Value = mylookup


Next i

End Sub

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,986
Default Excel VBA vlookup

You might get more attention if you post under the programming group.

" wrote:

Hello

This is my first Excel VBA to publish in the forum and happy to join
the Excel VBA family.

Excel vlookup function is very useful in many applications.

I develop a VBA to make Vlookup run faster if you many rows to lookup
and more user friendly , please try the code.

I appreciate your comment.

Option Explicit

Dim finalrow As Integer
Dim Mysheet As String
Dim mycolumn As Long
Dim Myrange As String
Dim mycount As Long
Dim i As Integer
Dim mylookup As Variant
Dim mystring As String
Dim myvalue As Long

Sub Vlookup()

mycolumn = Application.InputBox("Please enter the lookup column
number", Type:=1)
myvalue = Application.InputBox("Please enter the column number you want
to place your lookup up result ", Type:=1)
Mysheet = InputBox("Please enter lookup worksheet name",
"WorksheetName", Default)
Myrange = InputBox("Please enter lookup range", "Range", Default)

mycount = Range(Myrange).Columns.Count

On Error Resume Next

Columns(myvalue).Insert Shift:=xlToRight

finalrow = Cells(65536, mycolumn).End(xlUp).Row

For i = 1 To finalrow

mystring = (Cells(i, mycolumn))

mylookup = Application.Vlookup((mystring),
Worksheets(Mysheet).Range(Myrange), mycount, False)

Cells(i, myvalue).Value = mylookup


Next i

End Sub


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
Excel 2003 FAILS, but Excel 2000 SUCCEEDS ??? Richard Excel Discussion (Misc queries) 2 May 13th 23 11:46 AM
Link cells in Access to Excel using VLOOKUP dford Excel Discussion (Misc queries) 3 May 30th 06 09:07 AM
russian excel vlookup S.O'Reilly Excel Worksheet Functions 1 March 24th 06 06:16 PM
TRYING TO SET UP EXCEL SPREADSHEET ON MY COMPUTER MEGTOM New Users to Excel 5 October 27th 05 03:06 AM
VLOOKUP function in Excel 97 M. Weber Excel Worksheet Functions 1 January 10th 05 07:46 PM


All times are GMT +1. The time now is 01:58 PM.

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"