inputbox arab name problem when father, not when mother or both

littlepete

Well-known Member
Joined
Mar 26, 2015
Messages
507
Office Version
  1. 365
Platform
  1. Windows
hello :)

i have a perfectly well working inputbox asking if you would like to see the parents / mother / father of the person in the activerow.
no problems with option 2 and 3 and no problem with choosing mother in option 1.
is an inputbox keeping some kind of memory that could make the choice to see only the father ('s row) a problem?
each row is a person: the name is in column B. mother's name in CP; father's name in CQ. if it is a name in non latin letters,
the transcription is in CS and CT.
the inputbox finds the column of the activerow for mother/father's name then search for that name (identical) in column B.
all is working well, except for choosing father's name when both are available.

thank you for your opinion and advice !!!
this is the code:


VBA Code:
Sub vindouders() ' ------------------------------------------------------------------------------------------------- [ F4 ]
Dim keuze As Variant
Dim zoekmam As Range
Dim zoekpap As Range
Dim zoekma As Variant
Dim zoekpa As Variant
Dim dezerij As Long
Dim aantalcontacten As Variant
aantalcontacten = Worksheets("gegevens").Cells.SpecialCells(xlCellTypeLastCell).Row - 4
dezerij = ActiveCell.Row
zoekma = "*" & Range("cp" & dezerij).Value & "*"
Set zoekmam = Range("rngpersoon").Find(zoekma, , xlValues, xlWhole)
zoekpa = "*" & Range("cq" & dezerij).Value & "*"
Set zoekpap = Range("rngpersoon").Find(zoekpa, , xlValues, xlWhole)
' ========================================================== geen ma geen pa
If zoekmam Is Nothing And zoekpap Is Nothing Then
MsgBox Range("m" & dezerij).Value & " " & UCase(Range("n" & dezerij).Value) & Chr(10) & _
"heeft geen ouders staan in deze lijst. "
Exit Sub
End If
' ========================================================== wel ma wel pa
If Range("cp" & dezerij).Value <> "" And Range("cq" & dezerij).Value <> "" Then
If Range("cs" & dezerij).Value <> "" Or Range("ct" & dezerij).Value <> "" Then
keuze = InputBox(Chr(10) & _
    "Deze lijst bevat " & aantalcontacten & " contacten." & Chr(10) & Chr(10) & _
    "De ouders bekijken van " & Chr(10) & Range("p" & dezerij).Value & " : " & Chr(10) & _
     "______________________________________________________" & Chr(10) & _
    "tik 0 om dit scherm te verlaten." & Chr(10) & _
    "tik 1 om naar " & Range("cs" & dezerij).Value & " te gaan" & Chr(10) & _
    "tik 2 om naar " & Range("ct" & dezerij).Value & " te gaan" & Chr(10) & _
    Chr(10), "OUDERS BEKIJKEN VAN " & Range("m" & dezerij).Value & " " & UCase(Range("n" & dezerij).Value), , 11000, 10000)
Else
keuze = InputBox(Chr(10) & _
    "Deze lijst bevat " & aantalcontacten & " contacten." & Chr(10) & Chr(10) & _
    "De ouders bekijken van " & Chr(10) & Range("m" & dezerij).Value & " " & UCase(Range("n" & dezerij).Value) & " : " & Chr(10) & _
     "______________________________________________________" & Chr(10) & _
    "tik 0 om dit scherm te verlaten." & Chr(10) & _
    "tik 1 om naar " & Range("cp" & dezerij).Value & " te gaan" & Chr(10) & _
    "tik 2 om naar " & Range("cq" & dezerij).Value & " te gaan" & Chr(10) & _
    Chr(10), "OUDERS BEKIJKEN VAN " & Range("m" & dezerij).Value & " " & UCase(Range("n" & dezerij).Value), , 11000, 10000)
End If
Select Case keuze
    Case 0
    GoTo einde
    Case 1
        Range(zoekmam.Address).Select
        Exit Sub
    Case 2
        Range(zoekpap.Address).Select ' ==================================================== hier zit altijd een fout ==================
        Exit Sub
End Select
End If
[...]
 
"on error ..." makes it difficult to find errors, prevent them !
now, only the case with both parents is worth to examine.
VBA Code:
Sub vindouders()                                                ' ------------------------------------------------------------------------------------------------- [ F4 ]
     Dim keuze, zoekmam, zoekpap, zoekma, zoekpa, aantalcontacten     ' is the same as Variant for all of them
     Dim dezerij As Long, kind As String

     aantalcontacten = Worksheets("gegevens").Cells.SpecialCells(xlCellTypeLastCell).Row - 4
     dezerij = ActiveCell.Row
     If Range("p" & dezerij).Value <> "" Then
          kind = Range("p" & dezerij).Value
     Else
          kind = Range("m" & dezerij).Value & " " & Range("n" & dezerij).Value
     End If
     zoekma = Range("cp" & dezerij).Value                       'without "*"
     If Len(zoekma) > 0 Then Set zoekmam = Range("rngpersoon").Find("*" & zoekma & "*", , xlValues, xlWhole)
     zoekpa = Range("cq" & dezerij).Value
     If Len(zoekpa) > 0 Then Set zoekpap = Range("rngpersoon").Find("*" & zoekpa & "*", , xlValues, xlWhole)
    
      If zoekmam Is Nothing And zoekpap Is Nothing Then
          MsgBox Range("m" & dezerij).Value & " " & UCase(Range("n" & dezerij).Value) & Chr(10) & "heeft geen ouders staan in deze lijst. "
          Exit Sub
     End If

     If zoekmam Is Nothing Then Application.Goto zoekpap.Offset(, 1 - zoekpap.Column), 1     'just daddy, without asking goto 1e cell van de rij van pap
     If zoekpap Is Nothing Then Application.Goto zoekmam.Offset(, 1 - zoekmam.Column), 1     'just mammy, ithout asking goto 1st cell van de rij van pap

     MsgBox "you still have mammy and daddy", vbInformation

     ' ========================================================== ander alfabet
     If Range("cs" & dezerij).Value <> "" Then zoekpa = Range("cs" & dezerij).Value
     If Range("ct" & dezerij).Value <> "" Then zoekma = Range("ct" & dezerij).Value

     keuze = InputBox(Chr(10) & _
                      "Deze lijst bevat " & aantalcontacten & " contacten." & Chr(10) & Chr(10) & _
                      "De ouders bekijken van " & Chr(10) & Range("p" & dezerij).Value & " : " & Chr(10) & _
                      "______________________________________________________" & Chr(10) & _
                      "tik 0 om dit scherm te verlaten." & Chr(10) & _
                      "tik 1 om naar " & zoekpa & " te gaan" & Chr(10) & _
                      "tik 2 om naar " & zoekma & " te gaan" & Chr(10) & Chr(10) & _
                      "om nadien " & kind & " terug zelf te selecteren, druk op [ F2 ]." & Chr(10) & _
                      Chr(10), "OUDERS BEKIJKEN VAN " & Range("m" & dezerij).Value & " " & UCase(Range("n" & dezerij).Value), , 11000, 10000)

     Select Case keuze
          Case 0: MsgBox "einde"
          Case 1: zoekmam.Select
          Case 2: zoekpap.Select
          Case Else: MsgBox "this was not an option", vbCritical
     End Select

End Sub
what i don't understand: when i write vba i always try one thing: mother. if that works i copy the vba and just it to find dad. after that for both, combining both... then i add a check for non latin names...

how come all is working except each time the case of a dad with a non latin name?
where the code is as good as identical...

maybe it's something else not inputbox but elsewhere in the vba...

the error only shows by putting that line in yellow... is there a way to find what the error is?
 
Upvote 0

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
i found the error : object variable or block variable with not set ? error 91 ?
 
Upvote 0
Dim keuze, zoekmam As Range, zoekpap As Range, zoekma, zoekpa, aantalcontacten ' is the same as Variant for all of them
 
Upvote 0
Dim keuze, zoekmam As Range, zoekpap As Range, zoekma, zoekpa, aantalcontacten ' is the same as Variant for all of them
i have tried variant, long, range, string ... if that would be a problem then it would never work ! ;)
 
Upvote 0
is it okay now or still getting an error ?
hello :)

still stopping when person has both parents and i choose father that is arab (or non latin)...
i have a feeling it has to do with some memory (variables) problem?
 
Upvote 0
twice Exit sub at the end of those lines
VBA Code:
     If zoekmam Is Nothing Then Application.Goto zoekpap.Offset(, 1 - zoekpap.Column), 1: Exit Sub    'just daddy, without asking goto 1e cell van de rij van pap
     If zoekpap Is Nothing Then Application.Goto zoekmam.Offset(, 1 - zoekmam.Column), 1: Exit Sub    'just mammy, ithout asking goto 1st cell van de rij van pap
 
Upvote 0
the lines wouldnt be that simpel : first check if it's mom / dad / both then check if it's both latin name only one, and which one...
 
Upvote 0
hello :)

problem solved... not sure why but i did put in a language filter before the inputbox,
and not only in the inputbox itself... the problem has disappeared ...

THANKS for all the help !!! only one problem remaining now (other post) :
the not going together of my event activecell text in bold <> search vba ...

have a nice evening :) !!!

VBA Code:
If Range("cs" & dezerij).Value = "" Then ' ============================================= als p = transcript ingevuld dan vreemde mama
zoekma = "*" & Range("ax" & dezerij).Value & "*"
Else
zoekma = "*" & Range("cs" & dezerij).Value & "*"
End If
Set zoekmam = Range("rngpersoon").Find(zoekma, , xlValues, xlWhole)
 
Upvote 0
Solution
only conclusion, you didn't subcribe your problem good !
Your father was the problem in the inputbox, with a memory (impossible) and the solution was finding the mother with another value (if her name wasn't latin)
Can you debug your code (step by step in the VBA-editor), i guess you can't.
 
Upvote 0

Forum statistics

Threads
1,223,888
Messages
6,175,215
Members
452,618
Latest member
Tam84

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top