Specialty Forums
Security and Virus
General Hardware
CPUs/Overclocking
Networking
Digital Photo/Video
Office Software
PC Gaming
Console Gaming
Programming
Database
Web Development
Digital Home

General Forums
Windows XP
Windows Vista
Windows 95/98
Windows Me
Windows NT
Windows 2000
Win Server 2008
Win Server 2003
Windows 3.1
Linux
PDAs
BeOS
Novell Netware
OpenVMS
Solaris
Disk Op. System
Unix
Mac
OS/2

Drivers
Driver Scan
Driver Forum

Software
Automatic Updates

BIOS Updates

My Computing.Net

Solution Center

Free IT eBook

Howtos

Site Search

Message Find

RSS Feeds

Install Guides

Data Recovery

About

Home
Reply to Message Icon Go to Main Page Icon

Macro vlookup / hlookup help

Original Message
Name: MGHT
Date: May 1, 2008 at 14:16:47 Pacific
Subject: Macro vlookup / hlookup help
OS: windows xp
CPU/Ram: 500MB
Model/Manufacturer: Dell
Comment:
Hi I hope you can help me once again.

I have a file where constantly have to fill with expenses. On the left side are the accounts and on top the departments (kind like a pivot table).

I have to fill the file with info from another file pivot table (also account on the left side and departments on top) but on different order. Since not all the accounts on my report are on the original pivot table I use a vlookup to get the account and a hlookup to get the department. Then on the original Pivot table I put just below the last line a number that indicates the column number for the department is that way I get the column number for the vlookup.

Ex. “=vlookup(Account,OrgTable,hlookup(Dpt,OrgTable,x,0),0)” where I put of the Org table

I would like to find an easier and faster way to do this, since it is done frequently. i found a macro over the internet that works for a vlookup but how can I, either add a hlookup to this vlookup or tell the formula to look for the position of the department on the pivot table in order to set the column number for the vlookup.

Sub MatchValue()
Dim rListOne As Range
Dim rListTwo As Range
Dim iColDiff As Integer
On Error Resume Next
Set rListOne = Application.InputBox _
(Prompt:="Select the list WITH values, including the values. Don't include blank cells or headings", _
Title:="OzGrid.com", Type:=8)
If rListOne Is Nothing Then End
Set rListTwo = Application.InputBox _
(Prompt:="Select the list WITHOUT values. Don't include blank cells or headings", _
Title:="OzGrid.com", Type:=8)
If rListTwo Is Nothing Then End

iColDiff = WorksheetFunction.Max(rListOne.Column, rListTwo.Column) _
- WorksheetFunction.Min(rListOne.Column, rListTwo.Column)

rListTwo.Offset(0, 1).FormulaR1C1 = _
"=VLOOKUP(RC[-1]," & rListOne.Address _
(ReferenceStyle:=xlR1C1) & " ,2,FALSE)"
rListTwo.Offset(0, 1) = rListTwo.Offset(0, 1).Value
Set rListOne = Nothing
Set rListTwo = Nothing
On Error GoTo 0
End Sub

MHT


Report Offensive Message For Removal


Response Number 1
Name: DerbyDad03
Date: May 2, 2008 at 10:43:16 Pacific
Subject: Macro vlookup / hlookup help
Reply: (edit)
I'm not sure what kind of help you are looking for.

It appears that you know where the HLOOKUP goes in the formula - in place of the "2" in the VLOOKUP formula in the code.

What else were you looking for?


Report Offensive Follow Up For Removal

Response Number 2
Name: MGHT
Date: May 14, 2008 at 13:27:05 Pacific
Subject: Macro vlookup / hlookup help
Reply: (edit)
I think I figure out that its better to use a getpivot date formula! thanks anyway :D

MHT


Report Offensive Follow Up For Removal




Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: Macro vlookup / hlookup help

Comments:

 
  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 


Data Recovery Software




CPU and Graphics Upgrade Questions

VIRUS ALERT in Taskbar, HELP!

DSHUB24 Connection Problems

need help with dsl and dial up

novel 3.12


The information on Computing.Net is the opinions of its users. Such opinions may not be accurate and they are to be used at your own risk. Computing.Net cannot verify the validity of the statements made on this site. Computing.Net and Computing.Net, LLC hereby disclaim all responsibility and liability for the content of Computing.Net and its accuracy.
PLEASE READ THE FULL DISCLAIMER AND LEGAL TERMS BY CLICKING HERE

All content ©1996-2007 Computing.Net, LLC