Using a cell to find a row in another workbook and copy data

CodeRebel

New Member
Joined
Feb 22, 2023
Messages
8
Office Version
  1. 365
Platform
  1. Windows
I'm hoping somebody can point me in the right direction. I know how to extract data from another workbook on a server location using VBA.

But I'm afraid what I need may be a little more advanced than my ability.

I'm currently learning VBA for my company and I have a tool that compares a lot of data from other files and makes sure they all match.

1677721816329.png


I want to be able to type in a DR #in a field below. And VBA find the last used row in column B... and use that number in the cell as a search query to find a specific row in another workbook. Then copy the entire row back into another sheet in my tool workbook. The other workbook columns are fixed so I can manage to get it to copy/paste the data into the proper fields on my own. I think...

Thanks in advanced.
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
Hi,

To locate the last row in column B
VBA Code:
 lastrow = ActiveSheet.Cells(Rows.Count, "B").End(xlUp).Row
 
Upvote 0
Hi,

To locate the last row in column B
VBA Code:
 lastrow = ActiveSheet.Cells(Rows.Count, "B").End(xlUp).Row
Tha KS, but I was more concerned with being able to use that last row cell value to search other workbooks and copy and paste the rows from those workbooks into this workbook. All together.
 
Upvote 0
OK ...
But with no further details, you should adapt the following
VBA Code:
sndwbk.Cells.Find(What:=Range("B" & lastrow) , ....
 
Upvote 0
OK ...
But with no further details, you should adapt the following
VBA Code:
sndwbk.Cells.Find(What:=Range("B" & lastrow) , ....
I don't know how much detail I need to give. I don't want you to think I'm trying to get somebody to write the code for me. And I fear giving too much information might be confusing because it's just a piece of a much bigger tool.
 
Upvote 0
I don't know how much detail I need to give. I don't want you to think I'm trying to get somebody to write the code for me. And I fear giving too much information might be confusing because it's just a piece of a much bigger tool.
But... that helps. Thanks! I'll look into researching that code. I think it may be what I need.
 
Upvote 0
A pretty simple way to learn about the instruction Find ... is to turn on your macro recorder ... and hit Ctrl + F ... and go your the process once ...
You will get a "VBA translation" of your action ... which is a good starting point :)
 
Upvote 0
@CodeRebel - If you would like to post the solution then it is perfectly fine to mark your post as the solution to help future readers. Otherwise, please do not mark a post that doesn't contain a solution.
 
Upvote 0

Forum statistics

Threads
1,214,520
Messages
6,120,013
Members
448,935
Latest member
ijat

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