2

I am a VBA beginner...

Say I Have a "Customers" workbook where sheet1 contains names of my customers. Say I also have an other "CustomerData" workbook where each sheet contains the data concerning each specific customer. I.e. sheet1 in "CustomerData" concerns customer1 from "Customers" workbook.

I would like to be able to klick on each customer in "Customers" workbook and get the specific data concerning that customer from the "CustomerData" workbook.

How could I accomplish such a thing?

Best Regards!

K_B
  • 3,668
  • 1
  • 19
  • 29
user1665355
  • 3,324
  • 8
  • 44
  • 84

1 Answers1

1

There are 4 ways that I know about getting data from another workbook.

Sub OpenWorkbookToPullData()

    Dim path As String
    path = "C:\users\administrator\desktop\excelFile.xlsx"

    Dim currentWb As Workbook
    Set currentWb = ThisWorkbook

    Dim openWb As Workbook
    Set openWb = Workbooks.Open(path)

    Dim openWs As Worksheet
    Set openWs = openWb.Sheets("Sheet1")

    currentWb.Sheets("Sheet1").Range("A1") = openWs.Range("A1")

    openWb.Close (False)

End Sub
Community
  • 1
  • 1