object doesn t support this property or metod

I

Ivica Lopar

I have run time error "438"
object doesn t support this property or metod
in this line

Prod.Columnns(1).Name = "DATUM"

Can somebody help me this is my code


Sub Kreiraj()
Dim Dizv, Prod, Izv, Pt As Object
Dim Izvor As Range
Dim Dan, Mjesec, Godina As Integer
Dim Datum_p, Datum_zav As Date
Dim NoviRed As Long
Dim brojredova As Long

Set Prod = Worksheets("Prodaja")
Prod.Cells(1, 1).CurrentRegion.Name = "Podaci"
Prod.Columnns(1).Name = "DATUM"
Set Dizv = DialogSheets("DialogIzvjestaj")
Set Izv = Worksheets("Izvjestaj")
If Izv.ProtectContents = True Then
Izv.Unprotect
End If
Izv.Cells.Delete
If Dizv.OptonButtons(1).Value = xlOn Then
If Dizv.EditBoxes(1).Text <> "" Then
If IsDate(Dizv.EditBoxes(1).Text) Then
Dan = CDate(Dizv.EditBoxes(1).Text)
Else
MsgBox prompt:="Datum nije ispravno unesen", Buttons:=vbExclamation
Exit Sub
End If
Else
Dan = Date
End If
Prod.Cells(1, 10).Value = "DATUM"
Prod.Cells(2, 10).Value = Dan
Prod.Range("J1:J2").Name = "Kriterij"
Izv.Cells(1, 2).Value = "DNEVNI IZVJESTAJ "
Izv.Cells(2, 2).Value = "Dne:" & Dan
ElseIf Dizv.OptionButtons(2).Value = xlOn Then
If Dizv.EditBoxes(1).Text <> "" Then
If IsDate(Dizv.EditBoxes(1).Text) Then
Datum_p = CDate(Dizv.EditBoxes(1).Text) -
Weekday(CDate(Dizv.EditBoxes(1).Text)) + 2
Else
MsgBox prompt:="Datum nije ispravno unesen", Buttons:=vbExclamation
Exit Sub
End If
Else
Datum_p = Date - Weekday(Date) + 2
End If
Datum_zav = Datum_p + 7
Prod.Cells(1, 10).Value = "DATUM"
Prod.Cells(1, 11).Value = "DATUM"
Prod.Cells(2, 10).Value = ">=" & Datum_p
Prod.Cells(2, 11).Value = "<=" & Datum_zav
Prod.Range("J1:K2").Name = "Kriterij"
Izv.Cells(1, 2).Value = "TJEDNI IZVJESTAJ"
Izv.Cells(2, 2).Value = Datum_p & " - " & Datum_zav
ElseIf Dizv.OptionButtons(3).Value = xlOn Then
If Dizv.EditBoxes(1).Text <> "" Then
If IsDate(Dizv.EditBoxes(1).Text) Then
Mjesec = Month(CDate(Dizv.EditBoxes(1).Text))
Godina = Year(CDate(Dizv.EditBoxes(1).Text))
Else
MsgBox prompt:="Mjesc nije ispravno unesen", Buttons:=vbExclamation
Exit Sub
End If
Else
Mjesec = Month(Date)
Godina = Year(Date)
End If
Prod.Cells(1, 10).Value = "MJESEC"
Prod.Cells(2, 10).Formula = "=AND(MONTH(DATUM)= " & Mjesec & ",YEAR(DATUM)="
& Godina & ")"
Prod.Range("J1:J2").Name = "Kriterij"
Izv.Cells(1, 2).Value = "MJESECNI IZVJESTAJ"
Izv.Cells(2, 2).Value = "Mjesec:" & Mjesec & "/" & Godina
ElseIf Dizv.OptionButtons(4).Value = xlOn Then
If Dizv.EditBoxes(1).Text <> "" Then
If IsNumeric(Dizv.EditBoxes(1).Text) Then
Godina = Dizv.EditBoxes(1).Text
Else
MsgBox prompt:="Godina nije ispravno unesena", Buttons:=vbExclamation
Exit Sub
End If
Else
Godina = Year(Date)
End If
Prod.Cells(1, 10).Value = "GODINA"
Prod.Cells(2, 10).Formula = "=YEAR(DATUM)=" & Godina
Prod.Range("J1:J2").Name = "Kriterij"
Izv.Cells(1, 10).Value = "GODISNJI IZVJESTAJ"
Izv.Cells(2, 2).Value = "Godina: " & Godina
Else
If Dizv.EditBoxes(2).Text <> "" And Dizv.EditBoxes(3).Text <> "" Then
If IsDate(Dizv.EditBoxes(2).Text) And IsDate(Dizv.EditBoxes(3).Text) Then
Datum_p = CDate(Dizv.EditBoxes(2).Text)
Datum_zav = CDate(Dizv.EditBoxes(3).Text)
Else
MsgBox prompt:="Datumi nisu ispravno uneseni", Buttons:=vbExclamation
Exit Sub
End If
Else
MsgBox prompt:="Nedostaju podaci o razdoblju", Buttons:=vbExclamation
Exit Sub
End If

Prod.Cells(1, 10).Value = "DATUM"
Prod.Cells(1, 11).Value = "DATUM"
Prod.Cells(2, 10).Value = ">=" & Datum_p
Prod.Cells(2, 11).Value = "<=" & Datum_zav
Prod.Range("J1:K2").Name = "Kriterij"
Izv.Cells(1, 2).Value = "IZVJESTAJ ZA RAZDOBLJE"
Izv.Cells(2, 2).Value = Datum_p & " - " & Datum_zav
End If
NoviRed = Prod.Cells(1, 1).CurrentRegion.Rows.Count + 2
Range("Podaci").AdvancedFilter action:=xlFilterCopy,
criteriaRange:=Range("Kriterij"), copyToRange:=Prod.Cells(NoviRed, 1)
On Error GoTo LErr

Set Pt = Prod.PivotTableWizard(SourceType:=xlDatabase,
SourceData:=Prod.Cells(NoviRed, 1).CurrentRegion,
tableDestination:=Izv.Cells(5, 1), HasAutoFormat:=True)
Pt.AddFields RowFields:="KNJIGA"
Pt.PivotFields("UKUPNO").Orientation = xlDataField
Pt.PivotFields("KOMADA").Orientation = xlDataField
Pt.PivotFields("Data").Orientation = xlColumnField
Pt.PivotFields("Data").Name = "REZULTATI PRODAJE"
Pt.PivotFields("Sum of UKUPNO").NumberFormat = "#,##0.00"
Pt.PivotFields("Sum of UKUPNO").Name = "Iznos prodaje (kn)"
Pt.PivotFields("Sum of KOMADA").Name = "Broj prodanih knjiga"
Izv.Cells(1, 2).Font.Name = "HRHelvbold"
Izv.Cells(1, 2).Font.Size = 18
Izv.Cells(1, 2).Font.Bold = True

Izv.Cells(7, 1).CurrentRegion.AutoFormat Format:=xlClassic2
ActiveWorkbook.Names("Podaci").Delete
Prod.Cells(NoviRed, 1).CurrentRegion.Delete
If Dizv.ChekBoxes(1).Value = xlOn Then
brojredova = Izv.Cells(7, 1).CurrentRegion.Rows.Count
Set Izvor = Izv.Cells(7, 1).Resize(brojredova - 3, 2)
Izv.ChartObjects.Add(0, (brojredova + 8) * 12, 350, 220).Select
ActiveChart.ChartWizard Source:=Izvor, Gallery:=xlColumn, Format:=6,
PlotBy:=xlColumns, CategoryLabels:=1, SeriesLabels:=0, HasLegend:=2,
Title:="Knjge", ValueTitle:="Iznos prodaje (kn)", ExtraTitle:=""
End If
Izv.Protect
Exit Sub
LErr:
MsgBox prompt:="Nema podataka za odabrano razdoblje",
Buttons:=vbExclamation
ActiveWorkbook.Names("Podaci").Delete
Prod: Cells(NoviRed, 1).CurrentRegion.Delete
End Sub
 
D

Dave Peterson

Could it be you have too many n's in:

Columnns
maybe
Prod.Columns(1).Name = "DATUM"
would fix it.
 
I

Ivica Lopar

Now I have run time error "1004"
Application-defined or object defined error
in this line of code

ActiveWorkbook.Names("Podaci").Delete
 
C

Chip Pearson

You'll get that error if the name does not exist. Are you sure
you have such a name?


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
 
G

Guest

Sub Kreiraj()
Dim Dizv As Object
Dim Prod As Object
Dim Izv As Object
Dim Pt As Object
Dim Izvor As Range
Dim Dan As Integer
Dim Mjesec As Integer
Dim Godina As Integer
Dim Datum_p As Date
Dim Datum_zav As Date
Dim NoviRed As Long
Dim brojredova As Long

otherwise most of what you had declared will actually be of type variant...
 
I

Ivica Lopar

If I use this declaration nothing is hapennig


Jim Thomlinson said:
Sub Kreiraj()
Dim Dizv As Object
Dim Prod As Object
Dim Izv As Object
Dim Pt As Object
Dim Izvor As Range
Dim Dan As Integer
Dim Mjesec As Integer
Dim Godina As Integer
Dim Datum_p As Date
Dim Datum_zav As Date
Dim NoviRed As Long
Dim brojredova As Long

otherwise most of what you had declared will actually be of type
variant...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top