• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 152
  • Last Modified:

I have no idea why this is giving me a error: Windows(dataFile).Activate

I am coverting a Excel 97 spreadsheet to work with a new computer with
Excel 2003 installed, I am having some problems with querying collected
statistics to the data report file, I am getting the following error.


I am getting a "Run-time error '13' Type mismatch


Sub addStatsToDataFile()
    'adds the collected statistics (max and min right now) to the data
report file
    Dim x As Integer
    Dim localResult As Variant


    Application.StatusBar = "Adding statistical data in " & dataFile
    Windows(dataFile).Activate         ' THIS IS WHAT IS HIGHLIGHTED
WHEN I COMPILE
    Application.ScreenUpdating = False
    Selection.Name = "home" 'the current cell should be the last cell
(serial number column)
    Selection.Formula = "max:"
    stepRight 1
    For x = 1 To numberOfTests
        localResult = scaleStr(maxValue(x))
        Selection.Formula = localResult
        stepRight 1
        If x > 1 And x Mod 10 = 1 Then 'vertical page break after 10
columns...
            Selection.Formula = "max:"
            stepRight 1
        End If
    Next x
    Range("home").Select
    stepDown 1
    Selection.Formula = "min:"
    stepRight 1
    For x = 1 To numberOfTests
        localResult = scaleStr(minValue(x))
        Selection.Formula = localResult
        stepRight 1
        If x > 1 And x Mod 10 = 1 Then 'vertical page break after 10
columns...
            Selection.Formula = "min:"
            stepRight 1
        End If
    Next x
    Range("home").Select
End Sub


I am new to using VBA for Excel but I am a quick study, I need to pick
up where the last sys admin left off.


0
datatronics
Asked:
datatronics
1 Solution
 
gbzhhuCommented:
>>   Windows(dataFile).Activate         ' THIS IS WHAT IS HIGHLIGHTED WHEN I COMPILE

For this to work the datafile variable must contain a string that is the name of an open Excel window.  Is this the case?
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now