..|| Blog || Produkti/Storitve || MExcel || MDodatki || 300 nasvetov ||..

Iskanje - določanje

Pomoč pri izdelavi makrov

Iskanje - določanje

OdgovorNapisal/-a deraleks » Po maj 18, 2009 10:44 am

Želim, da makro naredi oznako v vrstici v kateri se celica ujema s celico na seznamu. Makro javlja napako v zvezi z deklaracijo spremeljivk. V vseh celicah je text.

Sub Premet()

Dim defin As Integer
Dim vsi As Integer
Dim x As Integer

x = 11 ' zamik v desno
For defin = 2 To 143 ' izbrani projekti

For vsi = 2 To 2267 ' vsi projekti

If Cells(defin, x).Value = Cells(vsi, x - 8).Value Then

Cells(vsi, x - 2).Value = "ta"

ActiveWindow.ScrollRow = vsi
End If
Next vsi

Next defin

End Sub
deraleks
 
Prispevkov: 23
Pridružen: Sr feb 28, 2007 10:28 pm



Matjazev.NET
 

OdgovorNapisal/-a admin » Po maj 18, 2009 11:25 am

Kakšno napako točno javi makro? Kaj ne deluje pravilno?
lp,
Matjaž Prtenjak
Administrator
admin
Site Admin
 
Prispevkov: 3526
Pridružen: Sr jul 20, 2005 10:06 pm

OdgovorNapisal/-a deraleks » Po maj 18, 2009 1:41 pm

Javi

Type mismatch (Error 13)

Visual Basic is able to convert and coerce many values to accomplish data type assignments that weren't possible in earlier versions. However, this error can still occur and has the following causes and solutions:

The variable or property isn't of the correct type. For example, a variable that requires an integer value can't accept a string value unless the whole string can be recognized as an integer.
Try to make assignments only between compatible data types. For example, an Integer can always be assigned to a Long, a Single can always be assigned to a Double, and any type (except a user-defined type) can be assigned to a Variant.

An object was passed to a procedure that is expecting a single property or value.
Pass the appropriate single property or call a method appropriate to the object.

A module or project name was used where an expression was expected, for example:
Debug.Print MyModule

Specify an expression that can be displayed.

You attempted to mix traditional Basic error handling with Variant values having the Error subtype (10, vbError), for example:
Error CVErr(n)

To regenerate an error, you must map it to an intrinsic Visual Basic or a user-defined error, and then generate that error.

A CVErr value can't be converted to Date. For example:
MyVar = CDate(CVErr(9))
deraleks
 
Prispevkov: 23
Pridružen: Sr feb 28, 2007 10:28 pm

OdgovorNapisal/-a admin » Po maj 18, 2009 1:44 pm

Kje točno javi to napako? In kako natančno izgleda tista vrstica s smeškom?
lp,
Matjaž Prtenjak
Administrator
admin
Site Admin
 
Prispevkov: 3526
Pridružen: Sr jul 20, 2005 10:06 pm

OdgovorNapisal/-a deraleks » Po maj 18, 2009 3:16 pm

Mislim, da coda deluje na številkah na tekstu pa ne. Podobno je s to:
Sub Premet()
Dim defin As Integer
Dim vsi As Integer
Dim x As Integer

x = 11 ' zamik v desno

For defin = 2 To 143 ' izbrani projekti

For vsi = 2 To 2267 ' vsi projekti
If Cells(defin, x).Value = Cells(vsi, x - 8).Value Then
Cells(defin, x + 1).Value = Cells(vsi, x - 10).Value And _
Cells(defin, x + 2).Value = Cells(vsi, x - 9).Value And _
Cells(defin, x + 3).Value = Cells(vsi, x - 7).Value And _
Cells(defin, x + 4).Value = Cells(vsi, x - 6).Value And _
Cells(defin, x + 5).Value = Cells(vsi, x - 5).Value
End If
Next vsi

ActiveWindow.ScrollRow = defin
'ActiveWorkbook.RefreshAll

Next defin


End Sub
deraleks
 
Prispevkov: 23
Pridružen: Sr feb 28, 2007 10:28 pm

OdgovorNapisal/-a admin » Po maj 18, 2009 6:40 pm

Hm... Zadnja koda nima smisla...

Tole lahko ima nek smisel:
Koda: Izberi vse
  Cells(defin, x + 1).Value = Cells(vsi, x - 10).Value
  Cells(defin, x + 2).Value = Cells(vsi, x - 9).Value
  Cells(defin, x + 3).Value = Cells(vsi, x - 7).Value
  Cells(defin, x + 4).Value = Cells(vsi, x - 6).Value
  Cells(defin, x + 5).Value = Cells(vsi, x - 5).Value


Če pa vmes tlačite operator 'AND' pa je to lahko kvečjemu testni pogoj (v npr. if stavku)!
lp,
Matjaž Prtenjak
Administrator
admin
Site Admin
 
Prispevkov: 3526
Pridružen: Sr jul 20, 2005 10:06 pm


Vrni se na VBA

Kdo je prisoten

Po forumu brska: 0 registriranih uporabnikov in 1 gost

cron