Foutmelding mbt onderbrekingsmodus bij selecteren sheet

Status
Niet open voor verdere reacties.

EdjeVis

Gebruiker
Lid geworden
22 nov 2006
Berichten
99
Goeie middag,

Wie kan/wil me helpen met een probleempje waar ik zelf niet uit kom.

Ik heb een stukje code, dat eerst op een werkblad een paar waarden in variabelen moet zetten, waarna in een ander werkblad eerst een van de gelezen waarden wordt gezocht en vervolgens een aantal waarden moet worden weggeschreven.

Echter, zodra de eerste de beste regel code uitgevoerd wordt, waar iets moet gaan gebeuren ("Sheets("CallDownload").Select"), volgt meteen de melding : "Kan de programmacode niet uitvoeren in de onderbrekingsmodus". Elke keer dat ik op OK klik, sluit een van de opties uit het lint (dus eerst "Start", daarna "Invoegen", etc.).

Code:
Option Explicit

'Algemene variabelen
Dim StrLocInCallDownl As String
Dim StrCallNr As String
Dim StrMAISCallPrio As String
Dim StrKlNrNm As String
Dim StrMAISStat As String
Dim StrMAISToegew As String
Dim StrOmschr As String
Dim dteAanmDat As String
Dim dteDatDownl As Date
Dim StrGevCallNr As String
Dim ObjGevCallNr As Object

'Kolomnummers Download:
Dim iCallNrKNDownl As Integer
Dim iOmschrKNDownl As Integer
Dim iMAISStatKNDownl As Integer
Dim iMAISToegewKNDownl As Integer
Dim iKlNrKNDownl As Integer
Dim iKlNmKNDownl As Integer
Dim iMAISCallPrioKNDownl As Integer
Dim iAanmDatKNDownl As Integer

'Kolomnummers Planning:
Dim iKlNrNmKNPlan As Integer
Dim iCallNrKNPlan As Integer
Dim iAanmDatKNPlan As Integer
Dim iOmschrKNPlan As Integer
Dim iLtstDatBijwKNPlan As Integer
Dim iLtstMAISCallPrioKNPlan As Integer
Dim iVorPrioKNPlan As Integer
Dim iLtstMAISToegewKNPlan As Integer
Dim iVorToegewKNPlan As Integer
Dim iLtstMAISStatKNPlan As Integer
Dim iVorStatKNPlan As Integer


Sub BijwerkenPlanningMetGegevensDownload()
'Zetten kolomnummers voor werkblad Download
iCallNrKNDownl = 2
iOmschrKNDownl = 3
iMAISStatKNDownl = 4
iMAISToegewKNDownl = 5
iKlNrKNDownl = 6
iKlNmKNDownl = 7
iMAISCallPrioKNDownl = 9
iAanmDatKNDownl = 10

'Zetten kolomnummers voor werkblad Planning
iKlNrNmKNPlan = 1
iCallNrKNPlan = 2
iAanmDatKNPlan = 5
iOmschrKNPlan = 6
iLtstDatBijwKNPlan = 9
iLtstMAISCallPrioKNPlan = 10
iVorPrioKNPlan = 11
iLtstMAISToegewKNPlan = 12
iVorToegewKNPlan = 13
iLtstMAISStatKNPlan = 14
iVorStatKNPlan = 15

'Sheets("CallDownload").Select
Cells(4, 2).Select

'Inlezen waarden uit tabblad Download
StrCallNr = Cells(ActiveCell.Row, iCallNrKNDownl).Value
StrOmschr = Cells(ActiveCell.Row, iOmschrKNDownl).Value
StrMAISStat = Cells(ActiveCell.Row, iMAISStatKNDownl).Value
StrMAISToegew = Cells(ActiveCell.Row, iMAISToegewKNDownl).Value
StrKlNrNm = Cells(ActiveCell.Row, iKlNrKNDownl).Value + "/ " + Cells(ActiveCell.Row, iKlNmKNDownl).Value
StrMAISCallPrio = Cells(ActiveCell.Row, iMAISCallPrioKNDownl).Value
dteAanmDat = Cells(ActiveCell.Row, iAanmDatKNDownl).Value

Sheets("Planning").Select

Columns("B:B").Select
'Selection.Find(What:=CallNr, After:=ActiveCell, LookIn:=xlFormulas, _
    LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
    MatchCase:=False, SearchFormat:=False).Activate
Range("B4").Select

With Selection
    Set ObjGevCallNr = .Find(StrCallNr, LookIn:=xlValues)

    If Not ObjGevCallNr Is Nothing Then
        Cells(ActiveCell.Row, iLtstDatBijwKNPlan).Value = dteDatDownl
        Cells(ActiveCell.Row, iVorPrioKNPlan).Value = Range(iLtstMAISCallPrioKNPlan & ActiveCell.Row).Value
        Cells(ActiveCell.Row, iLtstMAISCallPrioKNPlan).Value = StrMAISCallPrio
        Cells(ActiveCell.Row, iVorToegewKNPlan).Value = Range(iLtstMAISToegewKNPlan & ActiveCell.Row).Value
        Cells(ActiveCell.Row, iLtstMAISToegewKNPlan).Value = StrMAISToegew
        Cells(ActiveCell.Row, iVorStatKNPlan).Value = Range(iLtstMAISStatKNPlan & ActiveCell.Row).Value
        Cells(ActiveCell.Row, iLtstMAISStatKNPlan).Value = StrMAISStat
    Else
        Cells(ActiveCell.CurrentRegion.Rows + 1, iKlNrNmKNPlan).Select
        Cells(ActiveCell.Row, iKlNrNmKNPlan).Value = StrKlNrNm
        Cells(ActiveCell.Row, iCallNrKNPlan).Value = StrCallNr
        Cells(ActiveCell.Row, iAanmDatKNPlan).Value = dteAanmDat
        Cells(ActiveCell.Row, iOmschrKNPlan).Value = StrOmschr
        Cells(ActiveCell.Row, iLtstDatBijwKNPlan).Value = dteDatDownl
        Cells(ActiveCell.Row, iLtstMAISCallPrioKNPlan).Value = StrMAISCallPrio
        Cells(ActiveCell.Row, iLtstMAISToegewKNPlan).Value = StrMAISToegew
        Cells(ActiveCell.Row, iLtstMAISStatKNPlan).Value = StrMAISStat
    End If
End With
End Sub

Bij voorbaat dank voor je moeite!

Groeten,

EdjeVis
 
Dat selecteren is hoogstwaarschijnlijk niet nodig;

een stukje ipv: 'Sheets("CallDownload").Select en verder

Code:
with Sheets("CallDownload")

'Inlezen waarden uit tabblad Download
StrCallNr = .Cells(4, iCallNrKNDownl).Value
StrOmschr = .Cells(4, iOmschrKNDownl).Value
StrMAISStat = .Cells(4, iMAISStatKNDownl).Value
StrMAISToegew = .Cells(4, iMAISToegewKNDownl).Value
StrKlNrNm = .Cells(4, iKlNrKNDownl).Value + "/ " + .Cells(4, iKlNmKNDownl).Value
StrMAISCallPrio = .Cells(4, iMAISCallPrioKNDownl).Value
dteAanmDat = .Cells(4, iAanmDatKNDownl).Value

end with

Maar met een voorbeeldwerkboek waarin het ook fout gaat blijft het makkelijker schieten..
 
Hoi Eric,

Oké, je oplossing ga ik toepassen (ff kijken of me dat verder helemaal lukt), maar ik kan 't evengoed niet hebben dat ik dit probleem niet kan verklaren.
Bijgaand dan ook het bestand waarbij het probleem optreed. Hoop dat je er iets mee kunt.

Groet,
EdjeVis
 

Bijlagen

  • Voorbeeld Helpmij.zip
    29,8 KB · Weergaven: 71
De eerste foutmelding die ik tegenkom is:

Code:
 Cells(ActiveCell.Row, iVorPrioKNPlan).Value = Range(iLtstMAISCallPrioKNPlan & ActiveCell.Row).Value
deze gaat mis omdat je naar een range verwijst die niet bestaat, nml iLtstMAISCallPrioKNPlan = 10 & ActiveCell.Row = 4 dus je verwijst naar een range "104"

Dit gaat 2 en 4 regels later ook fout,
Voor de rest heb ik nog niet naar jouw code gekeken en wat je er überhaupt mee wil bereiken
 
snotver, gewoon toch niet goed gelezen.
nou, nu kom ik er zelf wel weer uit.
bedankt voor je moeite!
 
Status
Niet open voor verdere reacties.
Terug
Bovenaan Onderaan