Loop to run a task and to get part of the "intructions" from the next row

sdoppke

Well-known Member
Joined
Jun 10, 2010
Messages
647
Hi everyone, i know the title probably did more harm than good in explaining what im after. I have a column of URL's and need a loop to open the first URL check for a value in a cell (of the newly opened wb), return True or False in the main wb (in the cell of same row, next column of the URL), close the newly opened wb, then move, start ove on the next row, etc. till there are no more URL's to open.

Hope that made sence, thanks again for any help :)

sd
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
What 'part' of the instructions is on the next row?

You don't seem to have mentioned that part.

The main problem I can see is that you seem to want to open the workbooks using hyperlinks.

If you do that it might be hard to get a reference to the workbook and check for the value.

If you opened the workbook(s) in the 'usual' way it shouldn't be a problem.:)
 
Upvote 0
What 'part' of the instructions is on the next row?

You don't seem to have mentioned that part.

The main problem I can see is that you seem to want to open the workbooks using hyperlinks.

If you do that it might be hard to get a reference to the workbook and check for the value.

If you opened the workbook(s) in the 'usual' way it shouldn't be a problem.:)

The next row is the next URL. Its a column of 100 URL's. It should open the first URL, check for a value, return True or False in the cell left of the active cell (left of the cell that has the URL) then close and repeat, using the next URL(next row, same column) and return True or False (next row, left of URL column) and continue this process 100+ times.


Thanks a ton for taking the time to help. :)

sd
 
Upvote 0
That sounds pretty straightforward but I'm still unsure of the hyperlink thing.

Do you need to use hyperlinks?
 
Upvote 0
That sounds pretty straightforward but I'm still unsure of the hyperlink thing.

Do you need to use hyperlinks?

Yes, (totaly open to another way, if you are aware of one :) ) the .xlsx files are on our company sharepoint site. My only real aim is to check if they exist and return true or false, but ahve spent countless hours, to only come up with the laborous way of opening each file and returning a consitant value that each one has. to tell me if they exist or not. Sorry for the long explanation, but in short. I think i need to stick with the URL's.

sd
 
Upvote 0
I don't know much about Sharepoint, keep on meaning to find out more but...

Do you know if you can open a workbook in VBA like this?
Rich (BB code):
Dim strURL As String
 
      strURL = "\\mysharepoint.mycompany.com\myfile.xls"
 
     Workbooks.Open strURL
Obviously replace the URL with a real one.:)
 
Upvote 0
Right.

If you can do that then we don't really need to hyperlink.

Do you have all the URLs/paths/filenames/UNC etc?

ie whatever SharePoint uses
 
Upvote 0
Right.

If you can do that then we don't really need to hyperlink.

Do you have all the URLs/paths/filenames/UNC etc?

ie whatever SharePoint uses


I came up with this, but it does not move to the next active cell?
Code:
Sub test()
Dim strURL As String
On Error Resume Next
Worksheets("Sheet1").Range("I6").Select
strURL = ActiveCell
 For Each c In Worksheets("Sheet1").Range("I:I").Cells
  If c.Value <> " " Then Workbooks.Open strURL
        If Sheets("Week 1").Range("AT1") = "have" Then ActiveCell.Offset(0, -1) = "True" Else ActiveCell.Offset(0, -1) = "False"
 Next c
     
End Sub

I cant exactly figure how to get it to return False is no file is opened (found)

sd
 
Upvote 0

Forum statistics

Threads
1,224,598
Messages
6,179,823
Members
452,946
Latest member
JoseDavid

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