EXCEL FOR MAC VBA EXTRACT DATA FROM CLOSED WORKBOOK CODEYou can try to replace the code above with this: Dim fName As String, fPath As String, shtName As StringįPath = "C:\Users\folder1\My Documents\folder2\folder3\"įName = "filename.xlsx": shtName = "mySheet" For this you need to have a column in the source sheet that is always populated. With some formula that references the closed WB and catches automatically its last row. So you need to replace this part Set wb2 = Workbooks.Open(.) The last part of the code was my attempt at the beginning of incorporating the code into a for loop and pasting the data down with the same criteria. I've read that someone developed a code where you didn't have to open the workbook, but you needed the range pre determined, whereas mine is different depending on the last row. But since I've haven't found a way to do this without opening the workbook. I eventually want to get it so where it'll loop through the rest of the files. With ThisWorkbook.Sheets("Sheet1").Range("AQ2:FO2") Tgtlr = Cells(Rows.Count, 3).End(xlUp).Rowįpath = "C:\users\folder1\My Documents\folder2\folder3\"įname = "filename.xlsx": shtname = "filename" ' Disable screen updating to reduce screen flicker Option Explicitĭim fname As String, fpath As String, shtname As String I need the last row from the source data, but there are many workbooks and each one will have a different last row. I am trying to extract data from a closed workbook. ![]() I've searched the forum for similar topics but could never get a good answer. ![]() Application-defined or object-defined error.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |