ActiveChart.SetSourceData ¨Ó·½¸ê®Æ°ÝÃD (¤v¸Ñ¨M)
- ©«¤l
- 135
- ¥DÃD
- 19
- ºëµØ
- 0
- ¿n¤À
- 165
- ÂI¦W
- 0
- §@·~¨t²Î
- XP
- ³nÅ骩¥»
- 2003
- ¾\ŪÅv
- 20
- ©Ê§O
- ¨k
- ¨Ó¦Û
- »´ä
- µù¥U®É¶¡
- 2010-12-9
- ³Ì«áµn¿ý
- 2012-8-27
|
ActiveChart.SetSourceData ¨Ó·½¸ê®Æ°ÝÃD (¤v¸Ñ¨M)
¥»©«³Ì«á¥Ñ FAlonso ©ó 2011-3-13 15:21 ½s¿è
¾Þ§@ì·N¬O¦bB2¿ï¾Ü¶}©l¤é´Á,B3¿ï¾Üµ²§ô¤é´Á,B4¿ï¾Ü¼Æ¾Ú¦C(¨Ò¦p³Ì°ªÈ,³Ì§CÈ)µ¥,¦A³z¹Lµ{¦¡Ã¸µe¸Ó¼Æ¾Ú¦Cªº¹Ïªí
¥H¤Uµ{¦¡¦¨¥\¹B¦æ- Sub plotgraph()
- Dim myrange As Range, error As Boolean, x As Integer, y As Integer, mycolumn, mytitle
- With Sheet1
- .Activate
- .[a1].Activate
- End With
- error = False
- x = 0
- y = 0
- mytitle = [b4].Value
- If [b2] = "" Or [b3] = "" Then
- MsgBox "No date"
- Exit Sub
- End If
- If DateValue([a8]) > DateValue([b2]) Then
- MsgBox "Before starting period"
- error = True
- End If
- If DateValue([b3]) > DateValue([a41]) Then
- MsgBox "After ending period"
- error = True
- End If
- If error = True Then
- Exit Sub
- End If
- For Each myrange In Range([a8], [a65536].End(xlUp))
- If DateValue(myrange) >= DateValue([b2]) Then
- x = myrange.Row
- Exit For
- End If
- Next
- For Each myrange In Range([a8], [a65536].End(xlUp))
- If DateValue(myrange) > DateValue([b3]) Then
- y = myrange.Row - 1
- Exit For
- End If
- Next
- If mytitle = "¶}½L" Then
- mycolumn = "B"
- ElseIf mytitle = "³Ì°ª" Then
- mycolumn = "C"
- ElseIf mytitle = "³Ì§C" Then
- mycolumn = "D"
- ElseIf mytitle = "¦¬½L" Then
- mycolumn = "E"
- End If
- Sheet1.ChartObjects(1).Select
- ActiveChart.HasTitle = True
- ActiveChart.ChartTitle.Text = mytitle
- ActiveChart.HasLegend = False
- ActiveChart.SetSourceData Source:=Sheet1.Range("A" & x & ":" & "A" & y & "," & mycolumn & x & ":" & mycolumn & y), PlotBy:=xlColumns
- With Sheet1
- .Activate
- .[a1].Activate
- End With
- End Sub
½Æ»s¥N½X |
|
80 ¦r¸`¥H¤º
¤£¤ä«ù¦Û©w¸q Discuz! ¥N½X
|
|
|
|
|
- ©«¤l
- 135
- ¥DÃD
- 19
- ºëµØ
- 0
- ¿n¤À
- 165
- ÂI¦W
- 0
- §@·~¨t²Î
- XP
- ³nÅ骩¥»
- 2003
- ¾\ŪÅv
- 20
- ©Ê§O
- ¨k
- ¨Ó¦Û
- »´ä
- µù¥U®É¶¡
- 2010-12-9
- ³Ì«áµn¿ý
- 2012-8-27
|
¥»©«³Ì«á¥Ñ FAlonso ©ó 2011-3-13 15:22 ½s¿è
½Ð°Ñ¦Ò¥H¤Wµ{¦¡ |
|
80 ¦r¸`¥H¤º
¤£¤ä«ù¦Û©w¸q Discuz! ¥N½X
|
|
|
|
|
- ©«¤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 |
|
|
|
|
|
|