Cell Reference in Vlookup formula

seahawk56

New Member
Joined
Jun 23, 2008
Messages
30
I'm creating a production workbook that is using the VlookUp function to pull data from other workbooks. I would like to set it up so that when a new employee is added I can copy and past the formulas and it will adjust to pull the new employee's data. I'm learning how to apply constants and dimensions to make the formula short hand but I'm getting stuck on calling out the cell with the employee's name.

In the below examples the full Vlookup equation is really shortened by using the constants and dims but I'm having to change where to bring in the names (i.e. "Production Tracking\Andy C\Andy C ProdTrack"). As you can see by the VBA code (in the second box of "code") I'm having to call out the name in the code with (ActiveSheet.Range("P75").Value).

Thanks for the help,
Seahawk56


Code:
[SIZE=2]Full Vlookup equation:[/SIZE]
[SIZE=2]=IF(ISERROR(VLOOKUP($O77,'G:\ROC-CLAIMS\Clms Proc-Model Line\DMS\POS\Production Tracking\Andy C\Andy C ProdTrack_09166_09171.xls'!MonProd,2,FALSE)),0,VLOOKUP($O77,'G:\ROC-CLAIMS\Clms Proc-Model Line\DMS\POS\Production Tracking\Andy C\Andy C ProdTrack_09166_09171.xls'!MonProd,2,FALSE))[/SIZE]
 
[SIZE=2]VBA version with name cell as Dim: [/SIZE]
[SIZE=2]=IF(ISERROR(VLOOKUP($O76,MyStaff!MonProd,2,FALSE)),0,VLOOKUP($O76,MyStaff!MonProd,2,FALSE))[/SIZE]
 
[SIZE=2]What I would hope to go to:[/SIZE]
[SIZE=2]=IF(ISERROR(VLOOKUP($O76,MyLocation & StaffName(P75)!MonProd,2,FALSE)),0,VLOOKUP($O76,MyLocation & StaffName(P75)!MonProd,2,FALSE))[/SIZE]

Code:
Public Const MyFile As String = "POSdailyworkplanning"
Public Const MyLoc As String = "G:\ROC-CLAIMS\Clms Proc-Model Line\DMS\POS\Planned Work\"
Public Const MyProdFile As String = "ProdTrac"
Public Const MyProdLoc As String = "G:\ROC-CLAIMS\Clms Proc-Model Line\DMS\POS\Production Tracking\"
 
Public Sub ProdRollup(ByVal CellRef As String)
Dim MyWeek As String
Dim MyStaff As String
MyWeek = " " & MyProdFile & "_" & ConvertToJulian(ActiveSheet.Range("D1").Value) & "_" & ConvertToJulian(ActiveSheet.Range("E1").Value) & ".xls"
Debug.Print MyWeek
 MyStaff = MyProdLoc & (ActiveSheet.Range("P75").Value) & "\" & (ActiveSheet.Range("P75").Value) & MyWeek
Debug.Print MyStaff
End Sub
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.

Forum statistics

Threads
1,215,003
Messages
6,122,655
Members
449,091
Latest member
peppernaut

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top