Macro werkt niet meer.

Status
Niet open voor verdere reacties.

Atwist

Terugkerende gebruiker
Lid geworden
24 jan 2006
Berichten
1.055
Besturingssysteem
Wndows 10
Office versie
2016
Na een tijdje mijn "Teksten" sheet niet meer te hebben gebruikt, heb ik deze weer afgestoft maar tot mijn verbazing werkt de macro voor het op slaan van de tekst op de eerste vrije regel niet meer.
Bij mijn weten is er niet veranderd gebruik hiervoor altijd nog Excel 2003.
Zouden jullie eens kunnen kijken wat er mis zou kunnen zijn??????

Krijg de melding "Door de toepassing of door object gedefinieerde fout"


Alvast heel erg veel dank :thumb:

Code:
Private Sub CommandButton1_Click()
 Range("A2").Select
Dim iRow As Long
'Vind de eerste lege rij in uw textdatabase
iRow = Sheets("Teksten").Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
'check op invoer

If TextBox1.Value = "" Then
  TextBox1.SetFocus
 End If
 
Dim ct As Control
    For Each ct In Me.Controls
        If TypeOf ct Is msforms.ListBox Or TypeOf ct Is msforms.ComboBox Then
            ct.BackColor = vbWhite
            If ct.ListIndex < 0 Then ct.BackColor = vbWhite
        End If
    Next
  'copy the textdata to the textdatabase
With Sheets("Teksten")
  .Cells(iRow, 1).Value = ListBox1.Value
  .Cells(iRow, 2).Value = "***Text Item *****************************************************"
  .Cells(iRow, 3).Value = TextBox1.Value
  .Cells(iRow, 4).Value = TextBox2.Value
  .Cells(iRow, 5).Value = ":-L" & " " & ListBox2.Value
       
      If ListBox4 = "" Then
        .Cells(iRow, 6).Value = " "
        End If
    If ListBox4 <> "" Then
      .Cells(iRow, 6).Value = ":-w" & " " & ListBox4.Value
      End If
      
       If ListBox5 = "" Then
      .Cells(iRow, 7).Value = " "
    End If
    If ListBox5 <> "" Then
      .Cells(iRow, 7).Value = ":-sd" & " " & ListBox5.Value
    End If
      
      If ListBox8 = "" Then
        .Cells(iRow, 8).Value = " "
        End If
    If ListBox8 <> "" Then
      .Cells(iRow, 8).Value = ":-h" & " " & ListBox8.Value
      End If
      End With
      
      
'clear the tekstdata
ListBox1.Value = ""
TextBox1.Value = ""
TextBox2.Value = ""
ListBox2.Value = ""
ListBox4.Value = ""
ListBox5.Value = ""
ListBox8.Value = ""

CheckBox2.Value = False
CheckBox3.Value = False
CheckBox4.Value = False


 'ActiveWorkbook.
 Worksheets("Teksten").Sort.SortFields.Clear
    ActiveWorkbook.Worksheets("Teksten").Sort.SortFields.Add Key:=Range("A2"), _
        SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
    With ActiveWorkbook.Worksheets("Teksten").Sort
        .SetRange Range("A2:G3000")
        .Header = xlNo
        .MatchCase = False
        .Orientation = xlTopToBottom
        .SortMethod = xlPinYin
        .Apply
    End With
    
ListBox1.Enabled = False
ListBox2.Enabled = False
TextBox2.Enabled = False
Frame2.Enabled = False
CommandButton10.Enabled = False
    
End Sub
 
Laatst bewerkt:
Vertel er ook bij wat er niet werkt en of je een foutmelding krijgt.
Het lijkt me sowieso niet correct om een cel te vullen met een spatie i.p.v. hem leeg te maken.
 
Laatst bewerkt:
Hallo Ed,

Krijg de melding "Door de toepassing of door object gedefinieerde fout" op deze regel:

Code:
iRow = Sheets("Teksten").Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
 
Plaats dan het document.
De sheet Teksten bestaat wel?
 
Hallo Ed,

Sorry voor de late reactie een HD Crach heb alles weer nieuw moeten installeren en ben nu ook achter het probleem dat de macro niet werkte.
De tool was door mij gemaakt op een PC met waarschijlijk Excel 2007 draai nu met 2016 en het werkt weer, I by happy:cool::cool:

Dank voor het mee denken. :thumb:
 
Status
Niet open voor verdere reacties.
Terug
Bovenaan Onderaan