Hi guys,

I've got a work-related question here. I'm working with data generated by users, stored a password protected database. Let's call this file Database V3.0.xls I generated a report (pivot table) on usage per department and such. Here's the catch: I want to be able to update this pivot table when we start using a new database (Database 4.0). The lay-out will be identical, but it's crashed before so I want to have the freedom to update the database. I'm not the main user of the report file (my boss is), and I want to make life easy for him. So, let's say that I want cell B1 to containt *just* the version of the database; "3.0" or "4.0".



Here's what I'm trying so far:
Sub RefreshPivotTables()

Dim PT As PivotTable
Dim WbTarget As Workbook
Dim DataSource As Workbook
Dim WsTarget As Worksheet
Dim SourceName As Range
Dim DbaseV As String

Application.ScreenUpdating = False

DbaseV = [B1]
Set WbTarget = ThisWorkbook
Set WsTarget = WbTarget.ActiveSheet
Set DataSource = Workbooks.Open("C:\Directory\Database " & DbaseV & ".xls", , , , "Secret")
Set SourceName = DataSource.Worksheets("SpecificSheet").Range("A:Z")

For Each PT In WsTarget.PivotTables 'there might be 2/3 reports on the same data on one sheet, not clear on that yet but hardcoding to a specific pivot table seems like a bad idea
PT.SourceData = SourceName
Next PT

ActiveWorkbook.RefreshAll
DataSource.Close

Application.ScreenUpdating = True
End Sub
When testing, the line "PT.SourceData = SourceName" gives run-time error 1004, application-defined or object-defined error. I'm feeling like an idiot and I know it's probably something very easy but I'm running around in cirkles. Any help is appreciated!

Baron