Hi there, first post so sorry if I've broken any rules (I have searched this everywhere though).
I have several thound excel forms in a directory that fall into two (very similar) formats, and have written some code to pull cell D38 back into my summary sheet.
The problem I have is the difference between the two formats. If Cell C1 is populated with text then I need to pull back cell D38, if Cell D1 is populated with text then I need to pull back cell C20.
Any suggestions on how to do this?
I have several thound excel forms in a directory that fall into two (very similar) formats, and have written some code to pull cell D38 back into my summary sheet.
The problem I have is the difference between the two formats. If Cell C1 is populated with text then I need to pull back cell D38, if Cell D1 is populated with text then I need to pull back cell C20.
Any suggestions on how to do this?
Code:
Option Explicit
Sub fileinfo()
Dim myDir As String, fn As String, sn As String, sn2 As String, n As Long, NR As Long, ver As String
'***** Change Folder Path *****
myDir = "C:\Documents and Settings\test" 'for testing
'***** Change Sheetname(s) *****
sn = "PS1012 Assessment Matrix"
fn = Dir(myDir & "\*.xls")
Do While fn <> ""
If fn <> ThisWorkbook.Name Then
With ThisWorkbook.Sheets("Summary")
NR = .Cells(Rows.Count, 1).End(xlUp).Row + 1
With .Range("A" & NR)
.Formula = "='" & myDir & "\[" & fn & "]" & sn & "'!D38"
.Value = .Value
End With
End With
End If
fn = Dir
Loop
End Sub