ActiveChart.SetSourceData ¨Ó·½¸ê®Æ°ÝÃD (¤v¸Ñ¨M)
- ©«¤l
- 5923
- ¥DÃD
- 13
- ºëµØ
- 1
- ¿n¤À
- 5986
- ÂI¦W
- 0
- §@·~¨t²Î
- win10
- ³nÅ骩¥»
- Office 2010
- ¾\ŪÅv
- 150
- ©Ê§O
- ¨k
- ¨Ó¦Û
- ¥xÆW°ò¶©
- µù¥U®É¶¡
- 2010-5-1
- ³Ì«áµn¿ý
- 2022-1-23
        
|
¦^´_ 2# FAlonso
[·|¥X²{«¬ºA¤£²Å¦XªºÄµ¸¹,¸Ó¦p¦óÁ×§K?]
§Aªº¿ù»~¦b©ó쥻ªºµ{¦¡¦b°õ¦æ®É
ActiveSheet.Selection ¬O .ChartObjects(1) ¦Ó¤£¬O RANGE
×§ï§Aªºµ{¦¡¦p¤U
b2 b3 ½Ðª½±µ¿é¤J¤é´Á §Y¥i
- Sub plotgraph()
- Dim myrange As Range, error As Boolean, x As Integer, y As Integer
- Dim Rng As Range
- error = False
- x = 0
- y = 0
- With Sheet1
- .Activate
- .[a1].Activate
- '[·|¥X²{«¬ºA¤£²Å¦XªºÄµ¸¹,¸Ó¦p¦óÁ×§K?]
- '§Aªº¿ù»~¦b©ó쥻ªºµ{¦¡¦b°õ¦æ®É
- 'ActiveSheet.Selection ¬O .ChartObjects(1) ¦Ó¤£¬O RANGE
- Set Rng = .Range(.[a8], .[a65536].End(xlUp))
- If .[b2] = "" Or .[b3] = "" Then
- MsgBox "No date"
- error = True
- ElseIf .[b2] > .[b3] Then
- MsgBox .[b2] & ">" & .[b3]
- error = True
- ElseIf Rng(1) > .[b2] Then
- MsgBox "Before starting period"
- error = True
- ElseIf .[b3] > Rng(Rng.Count) Then
- MsgBox "After ending period"
- error = True
- End If
- If error = True Then Exit Sub
- For Each myrange In Rng
- If myrange >= .[b2] Then
- x = myrange.Row - 1
- Exit For
- End If
- Next
- For Each myrange In Rng
- If .[b3] <= myrange Then
- y = myrange.Row - 1
- Exit For
- End If
- Next
- If Sheet1.ChartObjects.Count = 0 Then Charts.Add
- .ChartObjects(1).Select
- ActiveChart.ChartType = xlLineMarkers
- ActiveChart.Location xlLocationAsObject, Name:="Sheet1"
- ActiveChart.HasDataTable = False
- .Activate
- If [b4] = "¶}½L" Then
- ActiveChart.SetSourceData Source:=.Range("A" & x & ":A" & y & ",B" & x & ":B" & y), PlotBy:=xlColumns
- ElseIf .[b4] = "³Ì°ª" Then
- ActiveChart.SetSourceData Source:=.Range("A" & x & ":A" & y & ",C" & x & ":C" & y), PlotBy:=xlColumns
- ElseIf .[b4].Value = "³Ì§C" Then
- ActiveChart.SetSourceData Source:=.Range("A" & x & ":A" & y & ",D" & x & ":D" & y), PlotBy:=xlColumns
- ElseIf .[b4].Value = "¦¬½L" Then
- ActiveChart.SetSourceData Source:=.Range("A" & x & ":A" & y & ",E" & x & ":E" & y), PlotBy:=xlColumns
- End If
- End With
- End Sub
½Æ»s¥N½X |
|
|
|
|
|
|