My boss asked me to pull some data from a big Excel spreadsheet. Basically she has two files, one of them has A, a one-dimensional list of experimental trials, and the other file has a worksheet B where column 1 corresponds to the names of the trials, and the rest of the columns have values for other attributes of the data. Presumably all the names in A are in B as well, but the script should accomodate it if that's not the case.
I want to take all the data from the columns of B whose value in the first row match the names from A, and paste those rows into a sheet C. Here's what I wrote:
Sub PullData()
For X = 1 To X = 100
Application.Goto Workbooks("A_Data.xls")
DataName = Workbooks("A_Data.xls").Sheets("Sheet1").Cells(X, 1)
Application.Goto Workbooks("B_Data.xls").Sheets("Sheet1").Range("A1:A1000")
Selection.Find(what:=ContNum, After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False).Acivate
targetrow = ActiveCell.Row
Rows(targetrow, targetrow).Select
Selection.Copy
Application.Goto Sheets("C").Cells(X, 1)
Selection.Paste
Next X
End Sub
----------------
When I run this, it doesn't actually do anything. I don't get any errors, but I don't get any output either. Obviously I'm missing something. If I'm being unclear about anything, please let me know and I'll try to explain it better.
Any suggestions would be greatly appreciated!
Bookmarks