Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 3rd, 2008, 08:01 AM
Registered User
 
Join Date: Jun 2008
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default VLookup with Strings Problem

How do you use a string in arg1 of vlookup?

I'm getting "Unable to get the VLookup property of the WorksheetFunction class" when using a string search.

    Dim HRCList As Range
        Set HRCList = Worksheets("New HRC List").Range("B9:L98")
Dim PortsList As Range
[ t]Set PortsList = Worksheets("Remote Apps").Range("B9:I98")
    Dim GetApp As String
    Dim GetPort As String
    Dim TotalApps As Integer
    Dim TotalPorts As Integer

This one works because I didn't define a string search. Before I got this to work, I was using a string in arg1. This string was equal to the argument in the formulat now and it didn't work. Obviously there is a catch I'm not getting.

    TotalApps = Application.WorksheetFunction.VLookup(Worksheets(" Customer Data").Cells(Counter + 2, 18), HRCList, 3, False)

This one does not, because of the string.
    GetPort = Application.WorksheetFunction.VLookup(GetApp, PortsList, TotalPorts + 2, False)


Thanks for any help you can provide.

dem
 
Old June 3rd, 2008, 10:46 AM
Registered User
 
Join Date: Jun 2008
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I hope someone can help me. I'm having trouble with my VB Vlookups with a string as the search arg1.

The following doesn't work because SystemCode is a String:

   ProductName = Application.WorksheetFunction.VLookup(SystemCode, Worksheets("New HRC List").Range("B9:C98"), 2, False)

This works because the SystemCode is defined:

   ProductName = Application.WorksheetFunction.VLookup(Worksheets(" Customer Data").Cells(Counter + 2, 18), Worksheets("New HRC List").Range("B9:C98"), 2, False)

What syntax will work with a string?





Similar Threads
Thread Thread Starter Forum Replies Last Post
Vlookup with VBA andygill Excel VBA 2 November 6th, 2008 06:44 PM
Problem with VLookup and DATEVALUE in VBA Sharadk74 Excel VBA 2 April 25th, 2008 09:30 AM
query strings problem saroo .NET Framework 2.0 1 October 23rd, 2007 06:41 AM
problem in the displaying two strings abhit_kumar JSP Basics 0 March 15th, 2005 05:56 AM
character to range conversion for VLOOKUP gskoog Excel VBA 1 May 26th, 2004 05:10 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.