View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Mike H Mike H is offline
external usenet poster
 
Posts: 11,501
Default Loop through a range Open a file

Hi,

Try this

Sub Marine()
Dim MyRange As Range
MyPath = "C:\"
Set MyRange = Range("AA3:AA33")
For Each c In MyRange
If UCase(c.Value) = "YES" Then
Workbooks.Open Filename:=MyPath & c.Offset(, -26).Value
End If
Next
End Sub
--
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.


"Thanks" wrote:

Hello
I have a range AA3:AA:33 that contains either "yes" or "no". and a list of
files (myfile.csv) in A3:A33 I would like to loop through the range AA3:AA33
and if the value is yes open the coresponding file in column A. The path to
the file is previously determined by code to be MyPath.
Thanks