Import cell value from a file that is hyperlink opened

Darnoky

New Member
Joined
Mar 5, 2018
Messages
7
Hello,

I need a help. I have an excel sheet with hyperlink pathes in Column A. (e.g.:A2, A3...etc.)

My purpose is to open each of them, so loop through

and when opened one check the opened one's sheet (1).Range("BP3").Value

and paste it back to orginal excel sheet, just next to the path (that is in column B) of the opened file.
Actually I could loop through the hyperlink pathes to open them, but do not know how to "look into":confused: the opened
file for data.

And of course close the opened file after a cell value is pasted.
One more info, all the hyperlinked files are ".CSV" files

Thank you for your help.
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
Hi

This might work for you;

Code:
Sub OpenFilesAndCopy()
Application.ScreenUpdating = False

LastRow = Range("A" & Rows.Count).End(xlUp).Row

For x = 1 To LastRow

    Workbooks.Open Cells(x, "A").Value
    NoS = Left(Dir(Cells(x, "A").Value), Len(Dir(Cells(x, "A").Value)) - 4)
    Worksheets(NoS).Range("BP3").Copy Range("B" & x)
    ActiveWorkbook.Close False
    
Next x

Application.ScreenUpdating = True
End Sub

This code should be pasted into the Sheet and not a Module.
 
Upvote 0
Hi

I copied it to the sheet and run it.
It stopped with error message of "Run-time eror '1004'.
Debugged: in codeline of Workbooks.Open Cells(X,"A").Value.
 
Upvote 0
Do you have an example of how your workbooks are listed in Column A?
 
Upvote 0
Uhm.... Not very helpful that ;-)

Can you just paste a text example, I just need to see what format the text string takes, how it looks in the cell.

Thanks :)
 
Upvote 0
Sorry for that. This was not my intention.

Here is one:
C:\Users\KALLAIL\Documents\2018\01\25\8A125A025_07_06_46_NOK_382332.csv
 
Last edited:
Upvote 0
Odd, that is how I assumed it would look.

OK - Try this?

Code:
Sub OpenFilesAndCopy()
Application.ScreenUpdating = False

LastRow = Range("A" & Rows.Count).End(xlUp).Row

For x = 1 To LastRow

    ThisWorkbook.FollowHyperlink Cells(x, "A").Value
    NoS = Left(Right(Cells(x, "A").Value, Len(Cells(x, "A").Value) - InStrRev(Cells(x, "A").Value, "\")), Len(Right(Cells(x, "A").Value, Len(Cells(x, "A").Value) - InStrRev(Cells(x, "A").Value, "\"))) - 4)
    Worksheets(NoS).Range("BP3").Copy Range("B" & x)
    ActiveWorkbook.Close False
    
Next x

Application.ScreenUpdating = True
End Sub
 
Upvote 0
This time,

Run-time error '5
Invalid procedure call or argument

I am not sure but maybe FollowHyperlink is a trouble one.

Or FollowHyperlink needs parenthesis expression.
 
Upvote 0
As much as I hate to say it, "it works fine on my machine" :-/

Sounds like the name of something is the problem.

When you open your CSV file normally, what name is Excel giving the worksheet?

I'd expect it to give it as "8A125A025_07_06_46_NOK_382332", the CSV files I have here and have been using are all named like PS0711, PS0611 etc and when I renamed one "8A125A025_07_06_46_NOK_382332" it named the sheet as that.
 
Upvote 0
Hi,

At end I found the problem was that x=1 but my Hyperlinked pathes started from A2, so it could not find any hyperlink to open.:)
After I removed empty row immediatelly solved the problem

Thank you very much.

It realy helped me and I could learned many things from that.

I appreciate your help very much!
 
Upvote 0

Forum statistics

Threads
1,223,974
Messages
6,175,737
Members
452,667
Latest member
vanessavalentino83

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