Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ' date: 190422
- ' autor: ***
- ' note: 處理tlm raw data用,初步擷取出有用的部份,以及作I-V圖
- ' 後續需要人工除去不必要的資料,再執行"main_tlm_cal"
- Sub main_tlm()
- 找所需資料的開端
- Dim SetupTitle_index As Integer
- ' 找出SetupTitle的index
- Cells(2, 28).Value = "=MATCH(""SetupTitle"",A:A, 0)"
- SetupTitle_index = Cells(2, 28).Value
- ' counter 用來決定貼到哪一欄
- Dim counter As Integer
- For counter = 1 To 20
- 貼上資料 SetupTitle_index, (2 * counter - 1) + 6
- ' 刪除處理好的raw data
- Range(Cells(1, 1), Cells(SetupTitle_index - 1, 4)).Delete xlUp
- If Cells(1, 1) = "" Then
- Exit For
- End If
- 找所需資料的開端
- Next counter
- 清除
- 給予current編號
- 作圖
- End Sub
- Sub 找所需資料的開端()
- ' 找出DataName的index
- Cells(2, 27).Value = "=MATCH(""DataName"",A:A, 0)"
- ' DataName上面的列,全部刪除
- Dim dataname_index As Integer
- dataname_index = Cells(2, 27).Value - 1
- ' 刪除
- Range("A1:D" & dataname_index).Delete xlUp
- End Sub
- Sub 貼上資料(nextdatarow As Integer, newpastecol As Integer)
- Range(Cells(1, 2), Cells(nextdatarow - 1, 3)).Copy
- Range(Cells(1, newpastecol), Cells(nextdatarow - 1, newpastecol)).PasteSpecial
- 'Range(Cells(1, 2), Cells(SetupTitle_index - 1, 2))
- End Sub
- Sub 清除()
- Range("A:F").Delete
- Dim i As Integer
- Dim index As Integer
- For i = 1 To 40
- If Cells(1, i) = "" Then
- index = i
- Exit For
- End If
- Next i
- Range(Cells(1, index), Cells(10, index + 10)).Delete
- End Sub
- Sub 給予current編號()
- Dim i As Integer
- For i = 2 To 20
- If Cells(1, i) = "" Then
- Exit For
- ElseIf Cells(1, i) = " V1" Then
- ' do nothing
- ElseIf Cells(1, i) = "V1" Then
- ' do nothing
- Else
- Cells(1, i).Value = "I" & i / 2
- End If
- Next i
- End Sub
- Sub 作圖()
- Range("A:A,B:B,D:D,F:F,H:H,J:J,L:L,N:N,P:P,R:R,T:T,V:V,X:X,Z:Z").Select
- Range("P1").Activate
- ActiveSheet.Shapes.AddChart2(240, xlXYScatterSmooth).Select
- ActiveChart.SetSourceData Source:=Range( _
- "A:A,B:B,D:D,F:F,H:H,J:J,L:L,N:N,P:P,R:R,T:T,V:V,X:X,Z:Z" _
- )
- ActiveChart.SetElement (msoElementPrimaryCategoryAxisTitleAdjacentToAxis)
- ActiveChart.SetElement (msoElementPrimaryValueAxisTitleAdjacentToAxis)
- ActiveChart.SetElement (msoElementChartTitleNone)
- ActiveChart.SetElement (msoElementLegendRight)
- ActiveChart.Axes(xlValue, xlPrimary).HasTitle = True
- ActiveChart.Axes(xlCategory).AxisTitle.Select
- ActiveChart.Axes(xlValue, xlPrimary).AxisTitle.Text = "V (V)"
- Selection.Format.TextFrame2.TextRange.Characters.Text = "V (V)"
- With Selection.Format.TextFrame2.TextRange.Characters(1, 5).ParagraphFormat
- .TextDirection = msoTextDirectionLeftToRight
- .Alignment = msoAlignCenter
- End With
- With Selection.Format.TextFrame2.TextRange.Characters(1, 5).Font
- .BaselineOffset = 0
- .Bold = msoFalse
- .NameComplexScript = "+mn-cs"
- .NameFarEast = "+mn-ea"
- .Fill.Visible = msoTrue
- .Fill.ForeColor.RGB = RGB(89, 89, 89)
- .Fill.Transparency = 0
- .Fill.Solid
- .Size = 10
- .Italic = msoFalse
- .Kerning = 12
- .Name = "+mn-lt"
- .UnderlineStyle = msoNoUnderline
- .Strike = msoNoStrike
- End With
- ActiveChart.Axes(xlValue).AxisTitle.Select
- ActiveChart.Axes(xlValue, xlPrimary).AxisTitle.Text = "I (A)"
- Selection.Format.TextFrame2.TextRange.Characters.Text = "I (A)"
- With Selection.Format.TextFrame2.TextRange.Characters(1, 5).ParagraphFormat
- .TextDirection = msoTextDirectionLeftToRight
- .Alignment = msoAlignCenter
- End With
- With Selection.Format.TextFrame2.TextRange.Characters(1, 5).Font
- .BaselineOffset = 0
- .Bold = msoFalse
- .NameComplexScript = "+mn-cs"
- .NameFarEast = "+mn-ea"
- .Fill.Visible = msoTrue
- .Fill.ForeColor.RGB = RGB(89, 89, 89)
- .Fill.Transparency = 0
- .Fill.Solid
- .Size = 10
- .Italic = msoFalse
- .Kerning = 12
- .Name = "+mn-lt"
- .UnderlineStyle = msoNoUnderline
- .Strike = msoNoStrike
- End With
- ' 設定位置
- With ActiveChart.Parent
- .Top = Range("D10").Top
- .Left = Range("D10").Left
- End With
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment