Objective: From within an Excel sheet I want a user to select another file to import. However, I only want it to import the source data if the header matches exactly what is located in the dashboard file.
Dashboard File: Field1,...,Field9 (row1) - worksheet name: Data
Data Source File: Field1,...,Field9 (row1) - worksheet name: Sheet 1
The above must exactly match or I need to throw an error the exits the sub.
Here are the code snippets which work independently, but I need help either swapping them out or working them together:
Not sure about this one...
Any help would be appreciated...
Dashboard File: Field1,...,Field9 (row1) - worksheet name: Data
Data Source File: Field1,...,Field9 (row1) - worksheet name: Sheet 1
The above must exactly match or I need to throw an error the exits the sub.
Here are the code snippets which work independently, but I need help either swapping them out or working them together:
Code:
Sub GetFile()Dim fNameAndPath As Variant, wb As Workbook
fNameAndPath = Application.GetOpenFilename(FileFilter:="Excel Files (*.XLS), *.XLS", Title:="Select File To Be Opened")
If fNameAndPath = False Then Exit Sub
Set wb = Workbooks.Open(fNameAndPath)
'
Call AddData
'
wb.Close savechanges:=True 'or false
End Sub
Not sure about this one...
Code:
Sub AddData() Dim i As Integer
Dim lw As Long
Dim j As Integer
lw = Range("E" & Rows.Count).End(xlUp).Row
For i = lw To 2 Step -1
If Range("E" & i).Value = "Yes" Then
For j = 7 To 13
Cells(i, j) = Date
Next j
End If
Next i
End Sub
Any help would be appreciated...