Herkese kolay gelsin.
Bir txt dosyasından 37000 satır civarında bilgiyi okutuyorum. Her biri yaklaşık 10000 satır büyüklüğünde üç grubum var. bunların her birini ayrı ayrı dosyalara kaydettikten sonra her birini kullanarak 4 adet grafik çizmem gerekli. Grafiği çizdirirken iki sütun kullanıyorum ama satır sayısının kaç olacağını bilemiyorum. bu yüzden aşağıdaki gibi bir ifade ile bu sorunu halletmeye kalktığımda bana
Run-time error 438
Object doesn't support this property or method
hatasını veriyor.
Bu sorunu nasıl çözebilirim?
Arkadaşlar dosya ektedir. Kodun tamamı ise şöyle:
[/code]
Bir txt dosyasından 37000 satır civarında bilgiyi okutuyorum. Her biri yaklaşık 10000 satır büyüklüğünde üç grubum var. bunların her birini ayrı ayrı dosyalara kaydettikten sonra her birini kullanarak 4 adet grafik çizmem gerekli. Grafiği çizdirirken iki sütun kullanıyorum ama satır sayısının kaç olacağını bilemiyorum. bu yüzden aşağıdaki gibi bir ifade ile bu sorunu halletmeye kalktığımda bana
Kod:
Sub grafik_ciz()
'ERİTME OCAÃI AKIM GRAFİÃİ HAZIRLANIYOR
Sheets(1).Select
Range("B:B,D:D").Select
Range("D1").Activate
Set my1 = Range("b1:b" & r)
Set my2 = Range("d1:d" & r)
Set myrange = Union(my1, my2)
' Set myr = Sheets(1).Range(myrange)
Charts.Add
ActiveChart.ChartType = xlLineStacked
ActiveChart.SetSourceData Source:=Sheets(1).Range(Union(my1, my2)), PlotBy:=xlColumns
Object doesn't support this property or method
hatasını veriyor.
Bu sorunu nasıl çözebilirim?
Arkadaşlar dosya ektedir. Kodun tamamı ise şöyle:
Kod:
Global dosya_adi, tarih As String
Global r As Long
Global my1, my2 As Range
Global myrange As Object
Sub Grafiklerrrrrrrrr()
'Application.ScreenUpdating = False
'DOSYA AÇILIYOR
Workbooks.OpenText Filename:="C:\documents and settings\mazam\Desktop\Kopya TextFile.txt", Origin _
:=xlWindows, StartRow:=1, DataType:=xlDelimited, TextQualifier:= _
xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, Semicolon:=False, _
Comma:=False, Space:=False, Other:=False, FieldInfo:=Array(Array(1, 4), _
Array(2, 1), Array(3, 1), Array(4, 1), Array(5, 1), Array(6, 1), Array(7, 1), Array(8, 1), _
Array(9, 1))
'GÜNLER AYRILIYOR
Call gun_ayir
End Sub
'GÜNLER AYRILIYOR
Function gun_ayir()
Dim r_eski As Integer
Range("A1").Select
Call isimlendirrrrrrrrrrrrr
r_eski = ActiveCell.Row
While ActiveCell.Value = ActiveCell.Offset(1, 0).Value
r = ActiveCell.Row + 1
c = ActiveCell.Column
ActiveCell.Offset(1, 0).Select
Wend
Rows(r_eski & ":" & r).Select
Selection.Cut
Workbooks.Add
Selection.Insert Shift:=xlDown
Columns("A:A").EntireColumn.AutoFit
baslik_yaz
Application.CutCopyMode = False
ActiveWorkbook.SaveAs Filename:=dosya_adi, FileFormat:=xlNormal, Password:="", _
WriteResPassword:="", ReadOnlyRecommended:=False, CreateBackup:=False
grafik_ciz
Windows("Kopya TextFile.txt").Activate
Rows(r_eski & ":" & r).Select
Selection.Delete Shift:=xlUp
If Range("A1") = "" Then End
Call isimlendirrrrrrrrrrrrr
gun_ayir
End Function
Function isimlendirrrrrrrrrrrrr()
'DOSYA İSMİ HAZIRLANIYOR
dosya_adi = "C:\Program Files\Shared Docs\Dokumhane\"
dosya_adi = dosya_adi & Mid(ActiveCell.Value, 1, 2)
Select Case Mid(ActiveCell.Value, 4, 2)
Case "01"
dosya_adi = dosya_adi & " Ocak " & "2005" & ".xls"
Case "02"
dosya_adi = dosya_adi & " Ãubat " & "2005" & ".xls"
Case "03"
dosya_adi = dosya_adi & " Mart " & "2005" & ".xls"
Case "04"
dosya_adi = dosya_adi & " Nisan " & "2005" & ".xls"
Case "05"
dosya_adi = dosya_adi & " Mayıs " & "2005" & ".xls"
Case "06"
dosya_adi = dosya_adi & " Haziran " & "2005" & ".xls"
Case "07"
dosya_adi = dosya_adi & " Temmuz " & "2005" & ".xls"
Case "08"
dosya_adi = dosya_adi & " Ağustos " & "2005" & ".xls"
Case "09"
dosya_adi = dosya_adi & " Eylül " & "2005" & ".xls"
Case "10"
dosya_adi = dosya_adi & " Ekim " & "2005" & ".xls"
Case "11"
dosya_adi = dosya_adi & " Kasım " & "2005" & ".xls"
Case "12"
dosya_adi = dosya_adi & " Aralık " & "2005" & ".xls"
End Select
tarih = Left(Replace(dosya_adi, "C:\Program Files\Shared Docs\Dokumhane\", _
"", 1, 39), Len(Replace(dosya_adi, "C:\Program Files\Shared Docs\Dokumhane\", _
"", 1, 39)) - 4)
End Function
Function baslik_yaz()
'SÜTUN BAÃLIKLARI YAZILIYOR
Rows("1:1").Select
Selection.Insert Shift:=xlDown
Range("A1").Select
ActiveCell.FormulaR1C1 = "TARİH"
Range("B1").Select
ActiveCell.FormulaR1C1 = "SAAT"
Range("C1").Select
ActiveCell.FormulaR1C1 = "SAAT"
Range("D1").Select
ActiveCell.FormulaR1C1 = "ERİTME OCAÃI AKIMI (A)"
Range("E1").Select
ActiveCell.FormulaR1C1 = "DİNLENME OCAÃI AKIMI (A)"
Range("F1").Select
ActiveCell.FormulaR1C1 = "DİNLENME OCAÃI SICAKLIÃI"
Range("G1").Select
ActiveCell.FormulaR1C1 = "KALIP GİRİÃ SICAKLIÃI"
Range("H1").Select
ActiveCell.FormulaR1C1 = "KALIP ÇIKIÃ SICAKLIÃI"
Range("I1").Select
ActiveCell.FormulaR1C1 = "KALIP ÇIKIÃ SICAKLIÃI"
Rows("1:1").Select
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
.WrapText = True
.Orientation = 0
.AddIndent = False
.ShrinkToFit = False
.MergeCells = False
End With
Cells.Select
Cells.EntireColumn.AutoFit
Range("G1").Select
Columns("D:D").ColumnWidth = 9.71
Columns("E:E").ColumnWidth = 9.71
Columns("F:F").ColumnWidth = 9.71
Columns("G:G").ColumnWidth = 9.14
Columns("H:H").ColumnWidth = 9.14
Columns("I:I").ColumnWidth = 9.14
End Function
Sub grafik_ciz()
'ERİTME OCAÃI AKIM GRAFİÃİ HAZIRLANIYOR
Sheets(1).Select
Range("B:B,D:D").Select
Range("D1").Activate
r = WorksheetFunction.CountA(Columns(2))
Set my1 = Range("b1:b" & r)
Set my2 = Range("d1:d" & r)
Set myrange = Union(my1, my2)
' Set myr = Sheets(1).Range(myrange)
Charts.Add
ActiveChart.ChartType = xlLineStacked
ActiveChart.SetSourceData Source:=Sheets(1).Range(Union(my1, my2)), PlotBy:=xlColumns
ActiveChart.Location Where:=xlLocationAsNewSheet, Name:="ERİTME OCAÃI AKIMI (A)"
With ActiveChart
.HasTitle = True
.ChartTitle.Characters.Text = "ERİTME OCAÃI AKIMI (A)" & " " & tarih
.Axes(xlCategory, xlPrimary).HasTitle = True
.Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text = "SAAT"
.Axes(xlValue, xlPrimary).HasTitle = True
.Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "(A)"
End With
With ActiveChart
.HasAxis(xlCategory, xlPrimary) = True
.HasAxis(xlValue, xlPrimary) = True
End With
ActiveChart.HasLegend = False
ActiveChart.HasDataTable = False
ActiveChart.ChartTitle.Select
Selection.AutoScaleFont = True
With Selection.Font
.Name = "Arial"
.FontStyle = "Kalın"
.Size = 20
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
.Background = xlAutomatic
End With
'DİNLENME OCAÃI AKIM GRAFİÃİ HAZIRLANIYOR
Sheets(1).Select
Range("B:B,E:E").Select
Range("E1").Activate
Charts.Add
ActiveChart.ChartType = xlLineStacked
ActiveChart.SetSourceData Source:=Sheets(1).Range( _
"B1:B" & r & ",E1:E" & r), PlotBy:=xlColumns
ActiveChart.Location Where:=xlLocationAsNewSheet, Name:="DİNLENME OCAÃI AKIMI (A)"
With ActiveChart
.HasTitle = True
.ChartTitle.Characters.Text = "DİNLENME OCAÃI AKIMI (A)" & " " & tarih
.Axes(xlCategory, xlPrimary).HasTitle = True
.Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text = "SAAT"
.Axes(xlValue, xlPrimary).HasTitle = True
.Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "(A)"
End With
With ActiveChart.Axes(xlCategory)
.HasMajorGridlines = False
.HasMinorGridlines = False
End With
With ActiveChart.Axes(xlValue)
.HasMajorGridlines = True
.HasMinorGridlines = False
End With
ActiveChart.HasLegend = False
ActiveChart.HasDataTable = False
ActiveChart.ChartTitle.Select
Selection.AutoScaleFont = True
With Selection.Font
.Name = "Arial"
.FontStyle = "Kalın"
.Size = 20
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
.Background = xlAutomatic
End With
'DİNLENME OCAÃI SICAKLIK GRAFİÃİ HAZIRLANIYOR
Sheets(1).Activate
Range("B:B,F:F").Select
Range("F1").Activate
Charts.Add
ActiveChart.ChartType = xlLineStacked
ActiveChart.SetSourceData Source:=Sheets(1).Range( _
"B1:B" & r & ",F1:F" & r), PlotBy:=xlColumns
ActiveChart.Location Where:=xlLocationAsNewSheet, Name:="DİNLENME OCAÃI SICAKLIÃI"
With ActiveChart
.HasTitle = True
.ChartTitle.Characters.Text = "DİNLENME OCAÃI SICAKLIÃI (0C)" & " " & tarih
.Axes(xlCategory, xlPrimary).HasTitle = True
.Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text = "SAAT"
.Axes(xlValue, xlPrimary).HasTitle = False
End With
ActiveChart.HasLegend = False
ActiveChart.HasDataTable = False
ActiveChart.ChartTitle.Select
Selection.AutoScaleFont = True
With Selection.Characters(Start:=1, Length:=26).Font
.Name = "Arial Tur"
.FontStyle = "Kalın"
.Size = 20
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
Selection.AutoScaleFont = False
With Selection.Characters(Start:=27, Length:=1).Font
.Name = "Arial Tur"
.FontStyle = "Kalın"
.Size = 20
.Strikethrough = False
.Superscript = True
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
Selection.AutoScaleFont = False
With Selection.Characters(Start:=28, Length:=Len(tarih) + 3).Font
.Name = "Arial Tur"
.FontStyle = "Kalın"
.Size = 20
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
'KALIP SICAKLIKLARI GRAFİÃİ HAZIRLANIYOR
Sheets(1).Select
Range("B:B,G:I").Select
Range("G1").Activate
Charts.Add
ActiveChart.ApplyCustomType ChartType:=xlBuiltIn, TypeName:= _
"2 Eksenli Çizgi"
ActiveChart.SetSourceData Source:=Sheets(1).Range( _
"B1:B" & r & ",G1:I" & r), PlotBy:=xlColumns
ActiveChart.Location Where:=xlLocationAsNewSheet, Name:="KALIP SICAKLIKLARI"
With ActiveChart
.HasTitle = True
.ChartTitle.Characters.Text = "KALIP SICAKLIKLARI (0C)" & " " & tarih
.Axes(xlCategory, xlPrimary).HasTitle = False
.Axes(xlValue, xlPrimary).HasTitle = False
.Axes(xlCategory, xlSecondary).HasTitle = False
.Axes(xlValue, xlSecondary).HasTitle = False
End With
With ActiveChart.Axes(xlCategory)
.HasMajorGridlines = False
.HasMinorGridlines = False
End With
With ActiveChart.Axes(xlValue)
.HasMajorGridlines = True
.HasMinorGridlines = False
End With
ActiveChart.HasLegend = True
ActiveChart.Legend.Select
Selection.Position = xlTop
With Selection.Border
.Weight = xlHairline
.LineStyle = xlAutomatic
End With
Selection.Shadow = False
With Selection.Interior
.ColorIndex = 15
.PatternColorIndex = 1
.Pattern = xlSolid
End With
ActiveChart.HasDataTable = False
ActiveChart.ChartTitle.Select
Selection.AutoScaleFont = False
With Selection.Characters(Start:=1, Length:=20).Font
.Name = "Arial Tur"
.FontStyle = "Kalın"
.Size = 20
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
Selection.AutoScaleFont = False
With Selection.Characters(Start:=21, Length:=1).Font
.Name = "Arial Tur"
.FontStyle = "Kalın"
.Size = 20
.Strikethrough = False
.Superscript = True
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
Selection.AutoScaleFont = False
With Selection.Characters(Start:=22, Length:=Len(tarih) + 3).Font
.Name = "Arial Tur"
.FontStyle = "Kalın"
.Size = 20
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
End Sub