Retrieve a data from other workbook

urielp

New Member
Joined
Nov 18, 2013
Messages
10
Hello,

I have a database in a range on Personal.xlsb workbook, in Sheet1. I would like to retreive the data from the other columns, using VBA.
I have this code. It works only while Personal.xlsb is activated. While I activate other workbook, I'm getting an error message (application defined or object defined error).

1. How to solve this issue?
2. Additional question: I would like to lookup the data in this range. For example, I would like to search for 'mrr factor' (row 7) using VBA. If found, to retreive the rest of the columns related to this row. How to do this? Note that Peronal.xlsb workbook is hidden.

Thanks,
Uriel

VBA Code:
Sub VBALookup()
Dim dRng As Range
Set dRng = Workbooks("personal.xlsb").Worksheets("sheet1").Range("A2", [A2].End(xlDown))
Set wsCopy = Workbooks("personal.xlsb").Worksheets("sheet1").Range("A2", [A2].End(xlDown))
Dim cel As Range
For Each cel In wsCopy.Cells
    pol = cel.Offset(0, 4).Value
Next cel
End Sub
 

Attachments

  • Database.png
    Database.png
    38.5 KB · Views: 5

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.

Forum statistics

Threads
1,214,620
Messages
6,120,554
Members
448,970
Latest member
kennimack

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