What is the VBA code to click on a Hyperlink, review the page and get back to the main sheet

farvardin

New Member
Joined
May 13, 2018
Messages
2
Hello,
I have a list with 3 columns:
Package Name:
Latest Date:
Link:

The VBA should click on the link, go to the linked sheet, capture a value and return to the main page.
I have a problem with writing a loop to go through the link in each row.
Can you please help:

[TABLE="width: 215"]
<colgroup><col><col><col></colgroup><tbody>[TR]
[TD]Package [/TD]
[TD]Date[/TD]
[TD]Link[/TD]
[/TR]
[TR]
[TD]kolabi Pack[/TD]
[TD]1-Jan-19[/TD]
[TD]VIC[/TD]
[/TR]
[TR]
[TD]Anjan Pack[/TD]
[TD]12-Aug-18[/TD]
[TD]TAS[/TD]
[/TR]
[TR]
[TD]Coala Pack[/TD]
[TD]4-Dec-18[/TD]
[TD]WA

[/TD]
[/TR]
</tbody>[/TABLE]

Code:

Sub Lop
Sheet1.Activate

count1 = Range("c2", Range("c1").End(xlDown)).Cells.count
y = 2
Do Until y = count1
Sheet1.Activate

Range("C" & y).Hyperlinks(Range("C" & y).Value).Follow NewWindow:=False, addhistory:=True

y = y + 1
Loop

end sub
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
Your wanting to retrieve some values from some sheets and return them some place.

Would you care to explain what your ultimate goal is.
A script should not need to activate hyperlinks and then do something

Where are the sheet names? Are they in column C?
And on the sheets where is the value you want returned?
And where do you want this value returned to?
 
Upvote 0
Hello,
Thanks for replying so quickly.
My ultimate goal is to capture the data from external link: "ProjectWise".
However, I am testing the options that VBA has for Hyperlinks.

TO answer you Qs:
Where are the sheet names? Are they in column C? Yes.
And on the sheets where is the value you want returned? Always on A1 & A2. Should be a fixed location
And where do you want this value returned to? Return them to Col D & E in the main sheet. or store them in Array.


Below is the latest code I wrote for testing and it is working fine:

Sub hyper()




Dim count1 As Long, t As Long
Dim y As Long
Sheet1.Activate
count1 = Range("c2", Range("c1").End(xlDown)).Cells.count


y = 2
Do Until y = count1 + 2
Sheet1.Activate


Range("C" & y).Select
Selection.Hyperlinks(1).Follow NewWindow:=False, AddHistory:=True
Range("A2").Copy Sheets("Sheet1").Range("C" & y).Offset(0, 1)
Range("B2").Copy Sheets("Sheet1").Range("C" & y).Offset(0, 2)
y = y + 1
Loop


Sheet1.Activate
MsgBox ("Extraction of " & count1 & " Links Completed")



End Sub
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,286
Members
452,631
Latest member
a_potato

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