Charli_Horse
New Member
- Joined
- Oct 11, 2017
- Messages
- 1
Hi all I have the following code that I am using to generate a set of discriptive statistics for a set of random numbers by using the . However when I try to loop through the action of refreshing the data set there is a popup. "That says Descriptive Statistics - Output will overwrite existing data. Press ok to overwrite data in range, "then it refrences the range of my output" for example Sheet2!$D$1:$E$15".
Currently I am using the Application.DisplayAlerts=False outside of the loop, but for some reason the popup continues to show up. Any help would be awesome as i am trying to create something to use the statistics on parts but want to automate it for a large range of parts with the popup it will make this very time consuming.
Here is the Code that I have come up with so far. Thanks for any help you can provide.
Sub Stats()
'
' Stats Macro
' Refreshes the descriptive Statistics
Dim x As Integer
'Clears the old statistics
Worksheets("Sheet3").Range("A2:F100").Clear
'' Arbitrary number of iterations
Application.DisplayAlerts = False
For x = 2 To 11
Application.CalculateFull
'Recorded from macro recorder is what is not its popup with the message seems to supersede Application.Display alerts off
Application.Run "ATPVBAEN.XLAM!Descr", ActiveSheet.Range("$A$1:$A$30"), _
ActiveSheet.Range("$D$1"), "C", True, True
Worksheets("Sheet3").Cells(x, 1).Value = Round(Worksheets("Sheet2").Range("E3").Value, 2)
Worksheets("Sheet3").Cells(x, 2).Value = Round(Worksheets("Sheet2").Range("E4").Value, 2)
Worksheets("Sheet3").Cells(x, 3).Value = Worksheets("Sheet2").Range("E5").Value
Worksheets("Sheet3").Cells(x, 4).Value = Worksheets("Sheet2").Range("E6").Value
Worksheets("Sheet3").Cells(x, 5).Value = Round(Worksheets("Sheet2").Range("E7").Value, 2)
Worksheets("Sheet3").Cells(x, 6).Value = Round(Worksheets("Sheet2").Range("E8").Value, 2)
Worksheets("Sheet3").Cells(x, 9).Value = Worksheets("Sheet2").Range("E13").Value
'add in one standard Deviation
Worksheets("Sheet3").Cells(x, 7).Value = Worksheets("Sheet3").Cells(x, 1).Value + Worksheets("Sheet3").Cells(x, 5).Value
Worksheets("Sheet3").Cells(x, 8).Value = Worksheets("Sheet3").Cells(x, 1).Value + (Worksheets("Sheet3").Cells(x, 5).Value * 2)
Worksheets("Sheet3").Cells(x, 10).Value = Worksheets("Sheet3").Cells(x, 7).Value - Worksheets("Sheet3").Cells(x, 9).Value
Worksheets("Sheet3").Cells(x, 11).Value = Worksheets("Sheet3").Cells(x, 8).Value - Worksheets("Sheet3").Cells(x, 9).Value
'
If Worksheets("Sheet3").Cells(x, 10).Value < 0 Then
Worksheets("Sheet3").Cells(x, 12).Value = Round(Worksheets("Sheet3").Cells(x, 8).Value, 0)
ElseIf Worksheets("Sheet3").Cells(x, 10).Value > 0 Then
Worksheets("Sheet3").Cells(x, 12).Value = Round(Worksheets("Sheet3").Cells(x, 7).Value, 0)
End If
Next x
Application.DisplayAlerts = True
End Sub
Currently I am using the Application.DisplayAlerts=False outside of the loop, but for some reason the popup continues to show up. Any help would be awesome as i am trying to create something to use the statistics on parts but want to automate it for a large range of parts with the popup it will make this very time consuming.
Here is the Code that I have come up with so far. Thanks for any help you can provide.
Sub Stats()
'
' Stats Macro
' Refreshes the descriptive Statistics
Dim x As Integer
'Clears the old statistics
Worksheets("Sheet3").Range("A2:F100").Clear
'' Arbitrary number of iterations
Application.DisplayAlerts = False
For x = 2 To 11
Application.CalculateFull
'Recorded from macro recorder is what is not its popup with the message seems to supersede Application.Display alerts off
Application.Run "ATPVBAEN.XLAM!Descr", ActiveSheet.Range("$A$1:$A$30"), _
ActiveSheet.Range("$D$1"), "C", True, True
Worksheets("Sheet3").Cells(x, 1).Value = Round(Worksheets("Sheet2").Range("E3").Value, 2)
Worksheets("Sheet3").Cells(x, 2).Value = Round(Worksheets("Sheet2").Range("E4").Value, 2)
Worksheets("Sheet3").Cells(x, 3).Value = Worksheets("Sheet2").Range("E5").Value
Worksheets("Sheet3").Cells(x, 4).Value = Worksheets("Sheet2").Range("E6").Value
Worksheets("Sheet3").Cells(x, 5).Value = Round(Worksheets("Sheet2").Range("E7").Value, 2)
Worksheets("Sheet3").Cells(x, 6).Value = Round(Worksheets("Sheet2").Range("E8").Value, 2)
Worksheets("Sheet3").Cells(x, 9).Value = Worksheets("Sheet2").Range("E13").Value
'add in one standard Deviation
Worksheets("Sheet3").Cells(x, 7).Value = Worksheets("Sheet3").Cells(x, 1).Value + Worksheets("Sheet3").Cells(x, 5).Value
Worksheets("Sheet3").Cells(x, 8).Value = Worksheets("Sheet3").Cells(x, 1).Value + (Worksheets("Sheet3").Cells(x, 5).Value * 2)
Worksheets("Sheet3").Cells(x, 10).Value = Worksheets("Sheet3").Cells(x, 7).Value - Worksheets("Sheet3").Cells(x, 9).Value
Worksheets("Sheet3").Cells(x, 11).Value = Worksheets("Sheet3").Cells(x, 8).Value - Worksheets("Sheet3").Cells(x, 9).Value
'
If Worksheets("Sheet3").Cells(x, 10).Value < 0 Then
Worksheets("Sheet3").Cells(x, 12).Value = Round(Worksheets("Sheet3").Cells(x, 8).Value, 0)
ElseIf Worksheets("Sheet3").Cells(x, 10).Value > 0 Then
Worksheets("Sheet3").Cells(x, 12).Value = Round(Worksheets("Sheet3").Cells(x, 7).Value, 0)
End If
Next x
Application.DisplayAlerts = True
End Sub