LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Ranges in VBA

Hi Guys

I hope you could help me out. I am building a general
search routine but getting stuck & manuplating range. I
have give the partial example below. It is supose to ask
the user select a column containg the list to search for
then. So its bacically an automated Vlookup routine.
However the part it fails is when passing on the column #
to the function. The passed value is a integer where as
function accepts range in "A1" style. I dont know how to
change etier method to make it work. Please advise . I use
Excel 2002 on Windows 2000

Sub test()
' ask the user which column has the list of part numbers
to search for

Set MPLPrice = Application.InputBox _
(Prompt:="Please Select the Sku Column to
Search", Title:=".", Type:=8)

If MPLPrice.Cells.Count = 0 Then Exit Sub
If MPLPrice.Columns.Count < 1 Then
MsgBox "You Can Only Select One Column for Sku Search"
& vbCrLf & "Please Try Agian", vbOKOnly +
vbInformation, "Boo Boo..."
Exit Sub
End If
' get the column number
MPLcol = MPLPrice.Column


' example of search, pass the part number, workbook &
worksheet + serach colun & search value to get column
PartNo = "1234-b21"
Res = SearchSku(PartNo, "ABC.XLS", "PriceList", MPLcol, 9)
MsgBox Res

End Sub

Function SearchSku(Pno As String, WB As String, Sheet As
String, SCol As String, GetCol As Integer)
Res = ""
Set r = Workbooks(WB).Sheets(Sheet).Range(SCol
& ":IV60000")
Res = Application.VLookup(Pno, r, GetCol, False)
If IsError(Res) Then
SearchSku = ""
Else
SearchSku = Res
End If

End Function

Thank you so much in advance
RB
 
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 copy formula that contains ranges so ranges do not overlap Patty Excel Worksheet Functions 1 November 20th 08 04:15 PM
HELP ON AGE RANGES Malcolm Austin Excel Worksheet Functions 4 July 31st 07 09:52 AM
3D Ranges David Excel Worksheet Functions 21 June 9th 05 06:11 PM
Like 123, allow named ranges, and print named ranges WP Excel Discussion (Misc queries) 1 April 8th 05 06:07 PM
Ranges Mona Excel Discussion (Misc queries) 1 December 17th 04 06:23 AM


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