Authorization
Visitors |
|
53570910 |
|
|
9380 |
|
|
113 |
|
|
|
Home
The voltage analysis in Microsoft Excel |
|
The script allows to derive the calculated voltages and their deviations from nominal in Microsoft Excel in a graphical form (as a voltage chart) and as the table with sorting. To use the script it is firstly need to download the steady state file.
Set objEx = CreateObject("Excel.Application")
objEx.SheetsInNewWorkbook = 1
objEx.Workbooks.Add
objEx.SheetsInNewWorkbook = 3
objEx.Worksheets(1).Name = "data"
Set tNode = Rastr.Tables("node")
dVstart = Array(4,4)
aHeaders = Array("node number","node name","dev dV%")
aColHeaders = Array("ny","name","otv")
CopyData dVstart(0),dVstart(1),objEx,tNode,aColHeaders
CreateHeader dVstart(0),dVstart(1),objEx,aHeaders,"Deviation from the nominal voltage by the nodes in %""
Sort objEx.Worksheets("data"),RangeA1(dVstart,0,1,3,tNode.Count),RangeA1(dVstart,3,1,3,1)
RangeY = RangeA1(dVstart,3,1,3,tNode.Count)
RangeX = RangeR1C1(dVstart,2,1,2,tNode.Count)
ChartGraph RangeY, RangeX, objEx, "Deviation from the nominal voltage by the nodes in %", "dV%"
objEx.Visible = true
Function RangeR1C1(aStart,OffsetX,OffsetY,EndX,EndY)
RangeR1C1 = ("R"& (aStart(0)+OffsetY) &"C"& (aStart(1)+OffsetX) &":"&_
"R"& (EndY+aStart(0)) &"C"& (aStart(1)+OffsetX))
End Function
Function RangeA1 (aStart,OffsetX,OffsetY,EndX,EndY)
RangeA1 = (Chr(65+aStart(1)-1+OffsetX)& (aStart(0)+OffsetY) &":"&_
Chr(65+aStart(1)-1+EndX)& (aStart(0)+EndY))
End Function
Sub CreateHeader(Ypoint,Xpoint,pObj,aHeaders,Header)
Set tObjData = pObj.Worksheets("data")
For i=LBound(aHeaders) to Ubound(aHeaders)
tObjData.Cells(Ypoint ,Xpoint+1+i).Value = aHeaders(i)
tObjData.Columns(Xpoint+i+1).autoFit
Next
tObjData.Cells(Ypoint-2,Xpoint).Value = Header
End Sub
Sub CopyData(Ypoint,Xpoint,pObj,pTable,aColHeaders)
Set tObjData = pObj.Worksheets("data")
For dCounter = Ypoint+1 To (pTable.Count+Ypoint)
tObjData.Cells(dCounter,dVstart(1)).Value = dCounter-dVstart(0)
Next
For i=LBound(aColHeaders) to UBound(aColHeaders)
For dCounter = YPoint+1 To (pTable.Count+Ypoint)
tObjData.Cells(dCounter,Xpoint+i+1).Value = pTable.Cols(aColHeaders(i)).Z(dCounter-Ypoint-1)
Next
Next
End Sub
Sub ChartGraph(RangeY,RangeX,pObj,CTitle,YTitle)
Set tObjData = pObj.sheets("data")
tObjData.Select
tObjData.Range(RangeY).Select
Set pObjChart = pObj.Charts.Add()
pObjchart.Name = YTitle
pObjChart.ChartType = 51
pObjChart.HasLegend = False
pObjChart.SeriesCollection(1).Name = CTitle
With pObjChart
.Axes(2, 1).HasTitle = True
.Axes(2, 1).AxisTitle.Characters.Text = YTitle
End With
With pObjChart.Axes(2)
.MinimumScale = -15
.MaximumScale = 15
.MinorUnit = 1
.MajorUnit = 5
.Crosses = -4105
.ReversePlotOrder = False
End With
pObjChart.PlotArea.Interior.ColorIndex = -4105
RangeX = "=data!"& RangeX
pObjChart.SeriesCollection(1).XValues = RangeX
pObjChart.HasAxis(1,1)= False
End Sub
Sub Sort(tData, RangeData, RangeBy)
tData.Range(RangeData).Sort tData.Range(RangeBy), 1, , , , , , 0,1, False, 1
End Sub
|
|
|