My FUNCTION takes person's UID and returns Dept from an external spreadsheet.
When I try to debug my function with F8, it just quits working (as a function- F8 debug worked as a sub). Any help would be great. By the way, here's some of the specific challenges I've run into:
* What I think I'm doing seems like it SHOULD be a common idea!
* I want to hardcode the whole path into the function.
* I tried moving the "sub" into the function, but that didn't work...then I tried calling the sub from the function (like below), but that doesn't work either
* I will write 2 or 3 functions like Get_Dept (Get_section, Get_Name) that will just return different column data form the directory workbook
Feel free to give me a suggestion from scratch! But, here's what I've got so far:
![]()
Public uid As String Public dept As String Public Sub getData(uid, dept As String) Dim wBook As Workbook Dim Dir_MRange As String Dim DirectoryRange As Variant ActiveWB = ActiveWorkbook.Name 'This workbook Set wBook = Workbooks.Open("C:\Users\myuser\Documents\REFERENCE\SAP\My Directory 05-2012.xlsx") ' Path to external Dir_MRange = "B2:B14740" 'This contains the UID to match from uidrow = Application.WorksheetFunction.Match(uid, wBook.Worksheets("Directory").Range(Dir_MRange), 0) dept = wBook.Worksheets("Directory").Range("I" & uidrow + 1).Offset(0, 0).Value 'The column of data to return is column "I" wBook.Close Set wBook = Nothing End Sub Public Function Get_Dept(uid_local As String) dept = "empty" uid = uid_local Call getData(uid, dept) Get_Dept = dept End Function
Any help would be GREATLY appreciated!
Bookmarks