Get value of last cell in column B from a closed workbook
Closed
BrianGreen
Posts
1005
Registration date
Saturday January 17, 2015
Status
Moderator
Last seen
September 30, 2021
-
Apr 16, 2015 at 05:54 PM
BrianGreen Posts 1005 Registration date Saturday January 17, 2015 Status Moderator Last seen September 30, 2021 - Apr 17, 2015 at 03:33 PM
BrianGreen Posts 1005 Registration date Saturday January 17, 2015 Status Moderator Last seen September 30, 2021 - Apr 17, 2015 at 03:33 PM
Related:
- Get value of last cell in column B from a closed workbook
- Lg tv closed caption - Guide
- Tentacle closed 2 - Download - Adult games
- Insert a function in cell b2 to display the current date from your system. ✓ - Excel Forum
- If cell contains date then return value ✓ - Excel Forum
- Excel "IF" function w/ date in test cell ✓ - Excel Forum
1 response
MaxStart
Posts
339
Registration date
Tuesday March 3, 2015
Status
Moderator
Last seen
July 3, 2015
69
Apr 17, 2015 at 02:26 AM
Apr 17, 2015 at 02:26 AM
VBA does not include a method to retrieve a value from a closed file. You can, however, take advantage of Excel's ability to work with linked files.
just like what you did, and I didn't !!!
There's a small trick which I prefer,
it's to open the file get the value and close it without having to see it being opened at all.
it goes like this:
just like what you did, and I didn't !!!
There's a small trick which I prefer,
it's to open the file get the value and close it without having to see it being opened at all.
it goes like this:
Sub go() Dim SRS As Workbook, FilePath As String, I As Integer, Cell As Range FilePath = ThisWorkbook.Path & "\Book1.xlsx" Application.ScreenUpdating = False Workbooks.Open (FilePath) Set SRS = Workbooks("Book1.xlsx") i = 1 With SRS Do Until SRS.Sheets(1).Cells(i, 2).Value = "" I = I + 1 Loop I = I - 1 Set Cell = SRS.Sheets(1).Cells(i, 2) MsgBox Cell.Value .Close End With Application.ScreenUpdating = True End Sub
Apr 17, 2015 at 01:45 PM
Im not sure I like opening up the closed workbook, but until I can find better, then I think this is what I will have to do.
I have found a different solution - much shorter, and not quite what I need yet, but at least gives me access to the data I need.
Here it is for those who want to try the same way ...
Apr 17, 2015 at 03:33 PM
Ok , so I got the value that I need from the above code, but ...
"data" is a number which is a count of the cells in column B of the closed workbook (calculated in that workbook).
What I need to do is incorporate this number into the range that I want copied from the closed workbook into the open workbook. Thus the code I have now is:
It goes horridly wrong at the mydata line with a run time error 13 - type mismatch.
Any ideas please?
Also how do I make the line above as absolute values - like ($B$4:$B$lastrow)
It seems so simple a task, but I just cant fathom it!
Thanks in advance for your suggestions.