- Katılım
- 2 Mart 2005
- Mesajlar
- 2,960
- Excel Vers. ve Dili
- ev: Ofis 2007- Win Xp
iş: Ofis 2010- Win Vista
DOSYA İndirmek/Yüklemek için ÜCRETLİ ALTIN ÜYELİK Gereklidir!
Altın Üyelik Hakkında Bilgi
Private Sub RunWOR_Click()
Dim WORarr As Variant
Dim I, x, Y, J As Integer
Dim cell1, cell2, xrange, yrange1, yrange2, yrange3 As Range
Dim chobj As ChartObject
I = 0 'Null counter before using
With WORSheet
While .Cells(3 + I, 1) <> ""
I = I + 1 'Determine maximum number of rows
Wend
ReDim WORarr(I, 11) As Variant 'Redim array to include full range
For x = 1 To I
WORarr(x, 1) = .Cells(x + 2, 1) 'Read in the date
WORarr(x, 2) = .Cells(x + 2, 2) 'Read bbl oil/month
WORarr(x, 3) = .Cells(x + 2, 3) 'Read bbl H2O/month
WORarr(x, 4) = WORarr(x, 2) / 1000 'Convert bbl oil/month to Mbbl oil/month
WORarr(x, 5) = WORarr(x, 3) / 1000 'Convert bbl H2O/month to Mbbl H2O/month
If x = 1 Then
WORarr(x, 6) = WORarr(x, 4) 'Calculate Mbbl Oil Cum
WORarr(x, 7) = WORarr(x, 5) 'Calculate Mbbl H2O Cum
Else
WORarr(x, 6) = WORarr(x - 1, 6) + WORarr(x, 4) 'Calculate Mbbl Oil Cum
WORarr(x, 7) = WORarr(x - 1, 7) + WORarr(x, 5) 'Calculate Mbbl H2O Cum
End If
WORarr(x, 8) = WORarr(x, 4) + WORarr(x, 5) 'Calculate Mbbl Total Liquids
If (WORarr(x, 2) <> 0) Then
WORarr(x, 9) = WORarr(x, 4) / WORarr(x, 8) 'Calculate Oil Cut %
Else
WORarr(x, 9) = 0 'If no oil then oil cut is 0%
End If
WORarr(x, 10) = 1 - WORarr(x, 9) 'Water cut based on oil cut
WORarr(x, 11) = WORarr(x, 5) / WORarr(x, 4) 'WOR calculated from Mbbl rates
For Y = 1 To 8
.Cells(x + 2, Y + 4) = WORarr(x, Y + 3) 'Display calculations for graph
Next Y
Next x
J = 0
For x = 1 To I
If (WORarr(x, 9) * 100) <> 0# Then
If WORarr(x, 10) * 100 <> 0# Then
If WORarr(x, 11) * 100 <> 0# Then
J = J + 1
.Cells(J + 2, 13) = WORarr(x, 6)
.Cells(J + 2, 14) = WORarr(x, 9)
.Cells(J + 2, 15) = WORarr(x, 10)
.Cells(J + 2, 16) = WORarr(x, 11)
End If
End If
End If
Next x
.Cells(2, 14) = "Oil Cut"
.Cells(2, 15) = "Water Cut"
.Cells(2, 16) = "WOR"
Set cell1 = .Cells(3, 13)
Set cell2 = Range(.Cells(J + 2, 13))
Set xrange = Range(cell1, cell2)
cell1 = ".Cells(3, 14)"
cell2 = ".Cells(J + 2, 14)"
Set yrange1 = Range(cell1, cell2)
cell1 = ".Cells(3, 15)"
cell2 = ".Cells(J + 2, 15)"
Set yrange2 = Range(cell1, cell2)
cell1 = ".Cells(3, 16)"
cell2 = ".Cells(J + 2, 16)"
Set yrange3 = Range(cell1, cell2)
With CutCum
.Clear
.ScreenUpdating = False
.Charts.Add
.DataSource = WORSheet
With .Charts(0)
.Type = chChartTypeLineMarkers
.SeriesCollection.Add
With .SeriesCollection(0)
.SetData chDimXValues, 0, xrange
.SetData chDimYValues, 0, yrange1
.SetData chDimSeriesNames, 0, "B14"
.Line.Color = "Green"
.Marker.Size = 3
End With
.SeriesCollection.Add
With .SeriesCollection(1)
[B][COLOR=Red] .SetData chDimXValues, 0, xrange
.SetData chDimYValues, 0, yrange2[/COLOR][/B]
.SetData chDimSeriesNames, 0, "B15"
.Line.Color = "Blue"
.Marker.Size = 3
End With
.HasLegend = True
.Legend.Position = ChartLegendPositionEnum.chLegendPositionBottom
.HasTitle = True
.Title.Caption = "Oil and Water Cut versus Oil Cum"
.Title.Font.Bold = True
.Title.Font.Size = 12
With .Axes(0)
.HasTitle = True
.Title.Caption = "Cumulative Oil (Mbbl)"
.Title.Font.Bold = True
.Title.Font.Size = 10
End With
With .Axes(1)
.HasTitle = True
.Title.Caption = "Oil Cut (Fraction)"
.Title.Font.Bold = True
.Title.Font.Size = 10
.Scaling.Maximum = 1
.Scaling.Minimum = 0.01
End With
With .Axes(2)
.HasTitle = True
.Title.Caption = "Water Cut (Fraction)"
.Title.Font.Bold = True
.Title.Font.Size = 10
.Scaling.Maximum = 1
.Scaling.Minimum = 0.01
End With
End With
End With
End With
End Sub
With DataAOF
' .ScreenUpdating = False
For I = 2 To 5
.Cells(I, 2) = Q(I)
.Cells(I, 3) = Pwssq(I) / 10 ^ 6
Next I
For I = 1 To 5
.Cells(I + 1, 5) = Q(I)
.Cells(I + 1, 6) = LSF(I) / 10 ^ 6
.Cells(I + 1, 8) = Q(I)
.Cells(I + 1, 9) = LSFsq(I) / 10 ^ 6
Next I
.Cells(1, 2) = "Measured"
.Cells(1, 5) = "Least Squares Fit"
.Cells(1, 8) = "Laminar Flow 1/n=1"
.Cells(2, 8) = AOFc(2)
End With
With AOFChart
.Charts.Add 'Makes a new chart
.DataSource = DataAOF
With .Charts(0)
.Type = chChartTypeScatterLine
.SeriesCollection.Add 'Put in a new series
With .SeriesCollection(0)
.SetData chDimSeriesNames, 0, "B1" 'Series name is "Cole"
.SetData chDimXValues, 0, "B2:B5"
.SetData chDimYValues, 0, "C2:C5"
End With
.SeriesCollection.Add 'Make a new series
With .SeriesCollection(1)
.SetData chDimSeriesNames, 0, "E1" 'Name new series "Least Squares Fit"
.SetData chDimXValues, 0, "E2:E6" 'Set x-values to xrange
.SetData chDimYValues, 0, "F2:F6" 'Set y-values to yrange
End With
.SeriesCollection.Add 'Make a new series
With .SeriesCollection(2)
.SetData chDimSeriesNames, 0, "H1" 'Name new series "Least Squares Fit"
.SetData chDimXValues, 0, "H2:H6" 'Set x-values to xrange
.SetData chDimYValues, 0, "G2:G6" 'Set y-values to yrange
End With
.HasLegend = True
.HasTitle = True 'Chart has a title
End With
' .ScreenUpdating = True
End With
güncel. ilgilnenlere teşekkür ederim.Siz SpreadShette raporlanan verilerin dinamik grafiğini almak için nasıl bir uol izlerdiniz?
o şekilde de yardımcı olsanız olur.
Dim iSonsatir As Integer
'------------------------
Private Sub CommandButton1_Click()
[COLOR=darkgreen]'Rassal olarak Yeni Veri Serilerimim ürerilmesi[/COLOR]
Call Serileri_Yeniden_Uret
[COLOR=darkgreen]'Üretilen Veri Serilerine göre grafiğin çizlmesi[/COLOR]
Call Grafigi_Yeniden_Ciz
End Sub
'--------------------------
Private Sub UserForm_Initialize()
Me.Caption = "OWC11 Spreadsheet ve ChartSpace Nesnelerinin Kullanımı için Örnek ..."
[COLOR=darkgreen]'Spreadsheet'in şekillendirilmesi[/COLOR]
With Spreadsheet1
.DisplayOfficeLogo = False
.DisplayTitleBar = False
.DisplayToolbar = False
With .ActiveWindow
.DisplayColumnHeadings = False
.DisplayRowHeadings = False
.DisplayWorkbookTabs = False
.DisplayHorizontalScrollBar = False
End With
End With
[COLOR=darkgreen]'Rassal olarak Yeni Veri Serilerinim ürerilmesi[/COLOR]
Call Serileri_Yeniden_Uret
[COLOR=darkgreen]'Üretilen Veri Serilerine göre grafiğin çizlmesi[/COLOR]
Call Grafigi_Yeniden_Ciz
End Sub
'-----------------------
Private Sub Serileri_Yeniden_Uret()
Dim i As Integer
Dim iSatirSayisi As Integer
Randomize
iSatirSayisi = CInt(Rnd() * 50) + 2
With Spreadsheet1
.Cells.Clear
.ActiveWindow.ViewableRange = "A1:C1000"
.Cells(1, 1) = "Kategoriler"
.Cells(1, 2) = "Seri-1"
.Cells(1, 3) = "Seri-2"
For i = 2 To iSatirSayisi
x = x + 1
.Cells(i, 1) = "Veri-" & x
.Cells(i, 2) = CInt(Rnd() * 1000)
.Cells(i, 3) = CInt(Rnd() * 500)
Next i
iSonsatir = .Cells(1000, 1).End(xlUp).Row
.ActiveWindow.ViewableRange = "A1:C" & iSonsatir
End With
End Sub
[COLOR=darkgreen]'----------------------------[/COLOR]
Private Sub Grafigi_Yeniden_Ciz()
With ChartSpace1
.Clear
.DataSource = Spreadsheet1
.Charts.Add
With .Charts(0)
.Type = chChartTypeLine
.SeriesCollection.Add
With .SeriesCollection(0)
.SetData chDimCategories, 0, Spreadsheet1.Range("A2:A" & iSonsatir).Address
.SetData chDimValues, 0, Spreadsheet1.Range("B2:B" & iSonsatir).Address
.Line.Color = "Green"
.Marker.Size = 3
End With
.SeriesCollection.Add
With .SeriesCollection(1)
.SetData chDimCategories, 0, Spreadsheet1.Range("A2:A" & iSonsatir).Address
.SetData chDimValues, 0, Spreadsheet1.Range("C2:C" & iSonsatir).Address
.Line.Color = "Red"
End With
End With
End With
End Sub
Hocam bunu Standart Grafik nesnesinde yapabildiğinizx biliyorum. peki Chartspace nesnesinde seri1 değeri 300 ü aşan kısımın grafik rengi turuncu olsun tekrar 300 ün altına düşünce kırmızı olsun bu münkün mü?
Bu bahsettiğiniz olayın temelinde; "XY Dağılım" grafiği vardır. Oysa ki; OWC içeren şu anki proje "Çizgi" grafik tipine göre dizayn edilmiştir. Onun için, grafik tipini değiştirmeden; iki nokta arasında kalan çizgilerin bir kısmının rengini turuncu, diğer kısmını kırmızı yapamazsınız.
Kaldı ki bahsettiğiniz olayı; XY Chart kullanılarak, sayfa üzerinde bile yapmak için, Geometrik hesaplamalar yapmak gerekir ki; attığımız taş ürküttüğümüz kuşa değer mi bilemiyorum. Çünkü, Y=300 noktasından geçen bir çizginin, diğer grafik çizgilerini kestiği noktalarının koordinatlarını bulmak gerekir. Yapılmaz değil ama, tam bir işkence olur![]()
Private Sub Grafigi_Yeniden_Ciz()
iSonsatir = sprCsf.Range("A100").End(xlUp).Row
With chrOkumalar
.Clear
.DataSource = sprOkumalar
.Charts.Add
With .Charts(0)
.Type = chChartTypeLine
.SeriesCollection.Add
With .SeriesCollection(0)
.Caption = "Reaktif/Aktif"
.SetData chDimCategories, 0, sprOkumalar.Range("A2:A" & iSonsatir).Address
.SetData chDimValues, 0, sprOkumalar.Range("f2:f" & iSonsatir).Address
.Line.Color = "Green"
.Marker.Size = 3
End With
.SeriesCollection.Add
With .SeriesCollection(1)
.Caption = "Kapasitif/Aktif"
.SetData chDimCategories, 0, sprOkumalar.Range("A2:A" & iSonsatir).Address
.SetData chDimValues, 0, sprOkumalar.Range("g2:g" & iSonsatir).Address
.Line.Color = "Red"
End With
' With .Axes(chAxisPositionLeft)
' .Scaling.Maximum = 1
' .Scaling.Minimum = 0
' ' .NumberFormat = "0.0%"
' .HasMajorGridlines = False
' End With
'
' With .Axes(chAxisPositionBottom)
' '.Scaling.Maximum = 30
' '.Scaling.Minimum = 0
' .NumberFormat = "dd.mm.yyyy"
' .HasMajorGridlines = False
' End With
.PlotArea.Interior.Color = "white" ' Display the legend.
.HasLegend = True
.Legend.Position = chLegendPositionBottom
End With
End With
End Sub



Private Sub Grafigi_Yeniden_Ciz()
isonsatir = sprCsf.Range("A100").End(xlUp).Row
Dim arrYatEks1(), arrDikEks1(), arrDikEks2()
With sprCsf
.Unprotect
.Columns("A:H").Sort 1, xlAscending, xlYes
grfYatEks1 = .Range("a2:a" & isonsatir).Address
grfDikEks1 = .Range("f2:f" & isonsatir).Address
grfDikEks2 = .Range("G2:G" & isonsatir).Address
' For I = 2 To iSonsatir
' ReDim Preserve arrYatEks1(I - 1)
' ReDim Preserve arrDikEks1(I - 1)
' ReDim Preserve arrDikEks2(I - 1)
' arrYatEks1(I - 2) = .Range("H" & I).Value
' arrDikEks1(I - 2) = .Range("F" & I).Value
' arrDikEks2(I - 2) = .Range("G" & I).Value
' Next I
' Stop
End With
With chrOkumalar
.Clear
.DataSource = sprOkumalar
.Charts.Add
With .Charts(0)
.Type = chChartTypeLine
.SeriesCollection.Add
With .SeriesCollection(0)
.Caption = "Reaktif/Aktif"
' .SetData chDimCategories, 0, sprCsf.Range("H2:H" & isonsatir).Address
' .SetData chDimValues, 0, sprCsf.Range("f2:f" & isonsatir).Address
.SetData chDimCategories, 0, grfYatEks1
.SetData chDimValues, 0, grfDikEks1
.Line.Color = "Green"
.Marker.Size = 3
End With
.SeriesCollection.Add
With .SeriesCollection(1)
.Caption = "Kapasitif/Aktif"
' .SetData chDimCategories, 0, sprCsf.Range("H2:H" & isonsatir).Address
' .SetData chDimValues, 0, sprCsf.Range("g2:g" & isonsatir).Address
.SetData chDimCategories, 0, grfYatEks1
.SetData chDimValues, 0, grfDikEks2
.Line.Color = "Red"
End With
With .Axes(chCategoryAxis)
.HasMajorGridlines = True
.Orientation = 90
.GroupingType = chAxisGroupingNone
.Font.Color = vbBlue
'.ReversePlotOrder = True
End With
' Stop
' With .Axes(chAxisPositionLeft)
' .Scaling.Maximum = 1
' .Scaling.Minimum = 0
' ' .NumberFormat = "0.0%"
' .HasMajorGridlines = False
' End With
'
.PlotArea.Interior.Color = "white" ' Display the legend.
.HasLegend = True
.Legend.Position = chLegendPositionBottom
End With
End With
With sprCsf
.Columns("A:H").Sort 1, xlDescending, xlYes
.Protect
End With
End Sub
Sorunumu çözdüm gibi yalnız bir sorun kaldı, o da Chartspace nesnesinde değerleri ters sırada göster komutunun vba karşılığı yardımlar için teşekkür ederim.
[/quate]
Güncel...
Sorunumu çözdüm gibi yalnız bir sorun kaldı, o da Chartspace nesnesinde değerleri ters sırada göster komutunun vba karşılığı yardımlar için teşekkür ederim.
[/quate]
Güncel... vba karşılığ nedir?