PCDVD數位科技討論區

PCDVD數位科技討論區 (https://www.pcdvd.com.tw/index.php)
-   七嘴八舌異言堂 (https://www.pcdvd.com.tw/forumdisplay.php?f=12)
-   -   [請益]excel 巨集 的errorbar要怎麼寫? (https://www.pcdvd.com.tw/showthread.php?t=896853)

lgla1982 2010-06-10 07:30 PM

[請益]excel 巨集 的errorbar要怎麼寫?
 
先說明!
我VB很遜....
但我不是來問作業答案的!

但還是希望厲害的網友們可以助我一臂之力,謝謝!

我在處理數據希望可以自動將圖裡面的資料加上errorbar,
但我寫出來的東西都執行不過∼
語法好像有問題∼!?但我也真的跟VB不太熟∼

我是加在百分比堆疊直條圖上的!

ActiveChart.SeriesCollection(3).Select
ActiveChart.SeriesCollection(3).HasErrorBars = True
ActiveChart.SeriesCollection(3).ErrorBars.Select
ActiveChart.SeriesCollection(3).ErrorBar Direction:=xlY, Include:=xlBoth, _
Type:=xlFixedValue, Amount:=C46:H46

現在的問題似乎卡在amount那一句,要怎樣才能夠指定error的值是特定一格,
或是一排資料?

如果有站上的朋友可以幫我解惑一下就太感激不盡了!
謝謝∼

michelle_lai529 2010-06-10 08:51 PM

引用:
作者lgla1982
先說明!
我VB很遜....
但我不是來問作業答案的!

但還是希望厲害的網友們可以助我一臂之力,謝謝!

我在處理數據希望可以自動將圖裡面的資料加上errorbar,
但我寫出來的東西都執行不過∼
語法好像有問題∼!?但我也真的跟VB不太熟∼

我是加在百分比堆疊直條圖上的!

ActiveChart.SeriesCollection(3).Select
ActiveChart.SeriesCollection(3).HasErrorBars = True
ActiveChart.SeriesCollection(3).ErrorBars.Select
ActiveChart.SeriesCollection(3).ErrorBar Direction:=xlY, Include:=xlBoth, _
Type:=xlFixedValue, Amount:=C46:H46

現在的問題似乎卡在amount那一句,要怎樣才能夠指定error的值是特定一格,
或是一排資料?

如果有站上的朋友可以幫我解惑一下就太感激不盡了!
謝謝∼

pm我吧,最近才為了幫公司行政搞一個excel的輸入介面,找到了一個excel vba的電子書,pm給我你的mail,我mail給你吧

joehsieh 2010-06-10 10:30 PM

也可以給我嗎? :) :)

michelle_lai529 2010-06-10 10:36 PM

引用:
作者joehsieh
也可以給我嗎? :) :)

pm給我你的mail吧...... :)

lgla1982 2010-06-11 03:33 PM

執行上還是不行

With ActiveChart.SeriesCollection(1)
.Select
.HasErrorBars = True
.ErrorBars.Select
.ErrorBar Direction:=xlX, Include:=xlBoth, _ <---到這邊還是會出錯!
Type:=xlCustom, _
Amount:="=sheet2!C46:H46", _
MinusValues:="=sheet2!C46:H46"
End With

我試過不是xlBoth的話就可以執行!
不知道為什麼?

fuckoil 2010-06-11 04:10 PM

引用:
作者lgla1982
執行上還是不行

With ActiveChart.SeriesCollection(1)
.Select
.HasErrorBars = True
.ErrorBars.Select
.ErrorBar Direction:=xlX, Include:=xlBoth, _ <---到這邊還是會出錯!
Type:=xlCustom, _
Amount:="=sheet2!C46:H46", _
MinusValues:="=sheet2!C46:H46"
End With

我試過不是xlBoth的話就可以執行!
不知道為什麼?



你是在 VB 呼叫的嗎 如果是 xlBoth 你必需查出他的值是多少再帶進來

lgla1982 2010-06-11 04:31 PM

引用:
作者fuckoil
你是在 VB 呼叫的嗎 如果是 xlBoth 你必需查出他的值是多少再帶進來

我是在excel 的VB視窗下呼叫的,
要怎麼查他的值??

lgla1982 2010-06-11 04:44 PM

引用:
作者lgla1982
我是在excel 的VB視窗下呼叫的,
要怎麼查他的值??

我在網路上有查到一個寫法:
Dim strErrorX As String
strErrorX = "=" & ActiveSheet.Name & "!" & Range("C1:C10").Address(ReferenceStyle:=xlR1C1)
With ActiveChart.SeriesCollection(1)
.ErrorBar Direction:=xlX, Include:=xlBoth, _
Type:=xlCustom, Amount:=strErrorX, MinusValues:= _
strErrorX
.ErrorBar Direction:=xlY, Include:=xlBoth, _
Type:=xlCustom, Amount:=strErrorX, MinusValues:= _
strErrorX
End With

但是他第二段我看不懂!?

diolin 2010-06-11 05:01 PM

引用:
作者lgla1982
我在網路上有查到一個寫法:
Dim strErrorX As String
strErrorX = "=" & ActiveSheet.Name & "!" & Range("C1:C10").Address(ReferenceStyle:=xlR1C1)
With ActiveChart.SeriesCollection(1)
.ErrorBar Direction:=xlX, Include:=xlBoth, _
Type:=xlCustom, Amount:=strErrorX, MinusValues:= _
strErrorX
.ErrorBar Direction:=xlY, Include:=xlBoth, _
Type:=xlCustom, Amount:=strErrorX, MinusValues:= _
strErrorX
End With

但是他第二段我看不懂!?


strErrorX 印出來, 就是 =Sheet1!R1C3:R10C3
基本上跟你自己寫是一樣的

我在 Excel 2000 試, 一條數列的 Amount 只能是單獨一個數值, 新版有修改嗎?

lgla1982 2010-06-12 03:24 AM

引用:
作者diolin
strErrorX 印出來, 就是 =Sheet1!R1C3:R10C3
基本上跟你自己寫是一樣的

我在 Excel 2000 試, 一條數列的 Amount 只能是單獨一個數值, 新版有修改嗎?

可以直接引用一行!

後來發現是我豬頭∼
ErrorBar Direction:=xlY

我寫成 xlX
所以才會出錯!
感謝各位∼!

總算可以自動作圖跟加上ERROR BAR...^^


所有的時間均為GMT +8。 現在的時間是03:20 AM.

vBulletin Version 3.0.1
powered_by_vbulletin 2025。