Configure Code of a big Project Userform

officeexcel2003

New Member
Joined
Sep 24, 2011
Messages
30
<hr style="color:#ebebeb; background-color:#ebebeb" size="1"> Hello Everybody,
could you help me to configure this userform for Excel2003, please?

I want to use this userform but I don't know VBA.
Download here!

Thank you very much.

I've tried to get help at an other forum but there couldn't be helped to me.

I would be very happy if you would paste your code at the same file or an other excel 2003 file.
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
Welcome to the Board!

I'm afraid that you won't find a whole lot of people willing (or able) to download files from external sources. It'll help if you describe what you have and what your desired results are.
 
Upvote 0
Hello Smitty,
thank you very much. I like this forum. It was surprising for me to see how many people join this forum.

The external Link is the Excel file with userform in it. I don't know where I better should upload the file because it is not possible at mrexcel?

What I have:
I have an Excel file with an coded userform. I want to use this Userform for data entry. The file contains mock data like name, email, telephonnumber etc. in it.

The Problem:

T
he data entry does'nt work because the textboxes and comboboxes of the userform doesn't match with the cells of excel and the listbox don't show the entries.
I don't understand which textbox is for which cell and how to match the form with excel.



 
Upvote 0
Unfortunately, you can't upload files here, but you can use screen shots (see my sig for how). As for viewing your file, a lot of people are blocked from file sharing sites, including me. But, you can post the code, the corresponding cells and what you want done and someone should be able to help you out.
 
Upvote 0
Which data should go in which textbox/listbox in the userform?

The most important one is the listbox as that seems to be used to identify things for displaying/updating.
 
Upvote 0

What I have:
I have an Excel file with an coded userform. I want to use this Userform for data entry. The file contains mock data like name, email, telephonnumber etc. in it.

The Problem:

T
he data entry does'nt work because the textboxes and comboboxes of the userform doesn't match with the cells of excel and the listbox don't show the entries. The Listbox should show ID, Name, Surname and Enterprise in a row.

The ID-numbers
should be given with consecutive numbering (1,2,3...) by program. Each number only occurs once so avoid double entries. If the User "cleans" with CommandButton5 the Text- and Commandboxes, the last not assigned number should appear in the Textbox1 so that the User can see the last free number and can enter a new dates. If the User enters another number which is already assigned, a MsgBox should warn with ["This number has already been assigned for the "Name" "Surname"] and the programm should assign again the last free number to the ID.


This is the new Version in English so you can see which data should go in which Textbox:

<embed src="http://www.box.net/embed/uip65ygg790qang.swf" width="466" height="400" wmode="opaque" type="application/x-shockwave-flash" allowFullScreen="true" allowScriptAccess="always">


 
Upvote 0
Furthermore I don't know if it is a efficient code and if it is a correct written program. My colleague wrote this code for this file but she is not more working and I have to use this excel file with this userform for the data entry.

@Chris Smitty: I don't understand VBA. This is a language like chinese for me and I don't understand chinese ;) I opened your HTML Maker Application from your signature but I don't know how to start it.


 
Last edited:
Upvote 0
Telefon

<table style="font-family:Arial,Arial; font-size:10pt; background-color:#ffffff; padding-left:2pt; padding-right:2pt; " border="1" cellpadding="0" cellspacing="0"> <colgroup><col style="font-weight:bold; width:30px; "><col style="width:24px;"><col style="width:60px;"><col style="width:38px;"><col style="width:58px;"><col style="width:69px;"><col style="width:131px;"><col style="width:42px;"><col style="width:60px;"><col style="width:102px;"><col style="width:95px;"><col style="width:102px;"><col style="width:102px;"><col style="width:95px;"><col style="width:88px;"><col style="width:96px;"><col style="width:95px;"><col style="width:156px;"><col style="width:179px;"><col style="width:71px;"><col style="width:71px;"><col style="width:71px;"><col style="width:346px;"><col style="width:80px;"><col style="width:42px;"><col style="width:63px;"></colgroup><tbody><tr style="background-color:#cacaca; text-align:center; font-weight:bold; font-size:8pt; "><td>
</td><td>B</td><td>C</td><td>D</td><td>E</td><td>F</td><td>G</td><td>H</td><td>I</td><td>J</td><td>K</td><td>L</td><td>M</td><td>N</td><td>O</td><td>P</td><td>Q</td><td>R</td><td>S</td><td>T</td><td>U</td><td>V</td><td>W</td><td>X</td><td>Y</td><td>Z</td></tr><tr style="height:18px ;"><td style="font-size:8pt; background-color:#cacaca; text-align:center; ">3</td><td>
</td><td>
</td><td>
</td><td>
</td><td>
</td><td>
</td><td>
</td><td>
</td><td>
</td><td>
</td><td>
</td><td>
</td><td>
</td><td>
</td><td>
</td><td>
</td><td>
</td><td>
</td><td>
</td><td>
</td><td>
</td><td>
</td><td>
</td><td style="background-color:#ff99cc; ">For Option Box:</td><td style="background-color:#ff99cc; ">
</td></tr><tr style="height:18px ;"><td style="font-size:8pt; background-color:#cacaca; text-align:center; ">4</td><td style="background-color:#ff99cc; font-weight:bold; ">ID:</td><td style="background-color:#ff99cc; font-weight:bold; ">Woman:</td><td style="background-color:#ff99cc; font-weight:bold; ">Man:</td><td style="background-color:#ff99cc; font-weight:bold; ">Name:</td><td style="background-color:#ff99cc; font-weight:bold; ">Surname:</td><td style="background-color:#ff99cc; font-weight:bold; ">Enterprise:</td><td style="background-color:#ff99cc; font-weight:bold; ">ZIP:</td><td style="background-color:#ff99cc; font-weight:bold; ">City:</td><td style="background-color:#ff99cc; font-weight:bold; ">Telefon 1:</td><td style="background-color:#ff99cc; font-weight:bold; ">Telefon 2:</td><td style="background-color:#ff99cc; font-weight:bold; ">Telefon 3:</td><td style="background-color:#ff99cc; font-weight:bold; ">Telefon 4:</td><td style="background-color:#ff99cc; font-weight:bold; ">Telefon 5:</td><td style="background-color:#ff99cc; font-weight:bold; ">Fax:</td><td style="background-color:#ff99cc; font-weight:bold; ">E-Mail:</td><td style="background-color:#ff99cc; font-weight:bold; ">Homepage:</td><td style="background-color:#ff99cc; font-weight:bold; ">Other Name&Surname:</td><td style="background-color:#ff99cc; font-weight:bold; ">Other Name&Surname 2:</td><td style="background-color:#ff99cc; font-weight:bold; ">Date:</td><td style="background-color:#ff99cc; font-weight:bold; ">Date 2:</td><td style="background-color:#ff99cc; font-weight:bold; ">Date 3:</td><td style="background-color:#ff99cc; font-weight:bold; ">Notices:</td><td>
</td><td style="background-color:#ff99cc; font-weight:bold; ">ZIP:</td><td style="background-color:#ff99cc; font-weight:bold; ">City:</td></tr><tr style="height:17px ;"><td style="font-size:8pt; background-color:#cacaca; text-align:center; ">5</td><td style="text-align:right; ">1</td><td>x</td><td>
</td><td>Eva</td><td>Bauer</td><td>Die Datei GmbH</td><td style="text-align:right; ">13455</td><td>Berlin</td><td>02023 4395421</td><td>09876 233565</td><td>0987 35626735</td><td>0988 35626735</td><td>0989 35626735</td><td>09875 253264</td><td style="color:#0000ff; text-decoration:underline; ">datei@gmb.de</td><td style="color:#0000ff; text-decoration:underline; ">www.asdf.com</td><td>Herr Soundso</td><td>Jemand</td><td style="text-align:right; ">02.03.1944</td><td style="text-align:right; ">22.12.2011</td><td style="text-align:right; ">03.03.2003</td><td>Hier können ganz viele Notizen stehen und dieser Text kann sehr lang werden. Deshalb höre ich jetzt auf zu schreiben.</td><td>
</td><td style="background-color:#ff00ff; text-align:right; ">13455</td><td style="background-color:#ff00ff; ">Berlin</td></tr><tr style="height:17px ;"><td style="font-size:8pt; background-color:#cacaca; text-align:center; ">6</td><td style="text-align:right; ">2</td><td>x</td><td>
</td><td>Sandra</td><td>Meier</td><td>
</td><td>
</td><td>
</td><td>09876 43143</td><td>063424 5342</td><td>
</td><td>0934 5622673</td><td>
</td><td>09876 253264</td><td style="color:#0000ff; ">
</td><td style="color:#0000ff; text-decoration:underline; ">www.qwer.de</td><td>Frau Soundso</td><td>Irgend</td><td>
</td><td>
</td><td>
</td><td>Dieser Text kann noch länger werden. Ist er aber nicht.</td><td>
</td><td style="background-color:#ff00ff; text-align:right; ">76432</td><td style="background-color:#ff00ff; ">Köln</td></tr><tr style="height:17px ;"><td style="font-size:8pt; background-color:#cacaca; text-align:center; ">7</td><td style="text-align:right; ">3</td><td>
</td><td>x</td><td>Albert</td><td>Einstein</td><td>Irgendeine Firma</td><td>
</td><td>
</td><td>05423 54211</td><td>0235 54783527</td><td>0457 542536723</td><td>0458 542536723</td><td>0991 35626735</td><td>09877 253264</td><td style="color:#0000ff; text-decoration:underline; ">asdf@hier.com</td><td style="color:#0000ff; ">
</td><td>
</td><td>Einer</td><td style="text-align:right; ">03.05.1966</td><td style="text-align:right; ">05.04.2011</td><td style="text-align:right; ">01.01.2001</td><td>Mal schauen, was mir sonst noch so einfällt.</td><td>
</td><td style="background-color:#ff00ff; text-align:right; ">08943</td><td style="background-color:#ff00ff; ">Hamburg</td></tr><tr style="height:17px ;"><td style="font-size:8pt; background-color:#cacaca; text-align:center; ">8</td><td style="text-align:right; ">4</td><td>x</td><td>
</td><td>Regina</td><td>Schmidt</td><td>Ein Unternehmen AG</td><td style="text-align:right; ">76432</td><td>Köln</td><td>
</td><td>0194 7483759</td><td>0458 56345723</td><td>0459 56345723</td><td>0992 35626735</td><td>
</td><td style="color:#0000ff; text-decoration:underline; ">datei@gmb.de</td><td style="color:#0000ff; text-decoration:underline; ">www.trwet.com</td><td>Keiner</td><td>Eine, Keine, Jede</td><td>
</td><td style="text-align:right; ">05.04.2011</td><td style="text-align:right; ">05.05.2005</td><td>Hier höre ich jetzt auf zu schreiben.</td><td>
</td><td style="background-color:#ff00ff; text-align:right; ">65332</td><td style="background-color:#ff00ff; ">München</td></tr><tr style="height:17px ;"><td style="font-size:8pt; background-color:#cacaca; text-align:center; ">9</td><td style="text-align:right; ">5</td><td>x</td><td>
</td><td>Lena</td><td>Schmitt</td><td>
</td><td>
</td><td>
</td><td>0143 08764329</td><td>
</td><td>
</td><td>
</td><td>0993 35626735</td><td>09879 253264</td><td style="color:#0000ff; ">
</td><td style="color:#0000ff; ">
</td><td>
</td><td>
</td><td style="text-align:right; ">08.06.2020</td><td style="text-align:right; ">03.01.2010</td><td>
</td><td>Eine Notiz sollte lieber nicht so lang sein. So wird doch niemand diese Notiz wahrnehmen. Also ich hätte das jetzt selbst nicht gelesen.</td><td>
</td><td style="background-color:#ff00ff; text-align:right; ">54232</td><td style="background-color:#ff00ff; ">Dortmund</td></tr><tr style="height:17px ;"><td style="font-size:8pt; background-color:#cacaca; text-align:center; ">10</td><td style="text-align:right; ">6</td><td>
</td><td>x</td><td>Christian</td><td>Schmidt</td><td>Fenster</td><td style="text-align:right; ">08943</td><td>Hamburg</td><td>0135 035356756</td><td>09876 547894</td><td>0460 0976723</td><td>0461 0976723</td><td>0994 35626735</td><td>09880 253264</td><td style="color:#0000ff; text-decoration:underline; ">jioew@gmx.net</td><td style="color:#0000ff; text-decoration:underline; ">www.gmx.net</td><td>Keine Ahnung</td><td>kennt niemanden ausser sich</td><td style="text-align:right; ">23.06.2011</td><td>
</td><td style="text-align:right; ">07.07.2007</td><td>Manchmal kommen auch 542354 Zahlen vor wie t623543u9hfdfas.</td><td>
</td><td style="background-color:#ff00ff; text-align:right; ">54236</td><td style="background-color:#ff00ff; ">Duisburg</td></tr><tr style="height:17px ;"><td style="font-size:8pt; background-color:#cacaca; text-align:center; ">11</td><td style="text-align:right; ">7</td><td>x</td><td>
</td><td>Maria</td><td>Albert</td><td>Bauamt</td><td style="text-align:right; ">65332</td><td>München</td><td>024565 4346</td><td>08472 52555</td><td>0468 988836723</td><td>0469 988836723</td><td>0995 35626735</td><td>09881 253264</td><td style="color:#0000ff; text-decoration:underline; ">jfwe@jio.com</td><td style="color:#0000ff; text-decoration:underline; ">www.jio.com</td><td>Fr. Keine </td><td>Angehör</td><td style="text-align:right; ">12.12.1999</td><td style="text-align:right; ">03.09.1943</td><td style="text-align:right; ">08.08.2008</td><td>
</td><td>
</td><td style="background-color:#ff00ff; text-align:right; ">76456</td><td style="background-color:#ff00ff; ">Aachen</td></tr><tr style="height:17px ;"><td style="font-size:8pt; background-color:#cacaca; text-align:center; ">12</td><td style="text-align:right; ">8</td><td>
</td><td>x</td><td>Albert</td><td>Einstein</td><td>Arbeitsamt</td><td>
</td><td>
</td><td>
</td><td>
</td><td>
</td><td>
</td><td>
</td><td>
</td><td>
</td><td>
</td><td>
</td><td>
</td><td>
</td><td>
</td><td>
</td><td>
</td><td>
</td><td style="background-color:#ff00ff; text-align:right; ">24567</td><td style="background-color:#ff00ff; ">Stuttgart</td></tr></tbody></table>

Excel Tabellen im Web darstellen >> Excel Jeanie HTML 4


jeanie.gif


The hole code of the Userform:
Code:
Option Explicit



Private Sub ComboBox1_Change()
ComboBox1 = (ComboBox1)
ComboBox1 = Evaluate("=PROPER(" & """" & ComboBox1 & """" & ")")
End Sub

Private Sub ComboBox2_Change()
On Error Resume Next
ComboBox2 = (ComboBox2)
Dim MyRange As Range
Dim noA As Integer
ListBox1.Clear
noA = WorksheetFunction.CountA(Sheets("Telefon").Range("B:B"))
For Each MyRange In Sheets("Telefon").Range("B3:B" & noA)
If Left(LCase(MyRange), Len(ComboBox2)) = LCase(ComboBox2) Then ListBox1.AddItem (MyRange)
Next
End Sub



Private Sub CommandButton1_Click()
On Error Resume Next
Sheets("Telefon").Select
Dim bak As Range '****
Dim say As Integer

''''''''''''''''''''''''
For Each bak In Range("B1:B" & WorksheetFunction.CountA(Range("B1:B65000")))
If StrConv(bak.Value, vbUpperCase) = StrConv(ComboBox1.Value, vbUpperCase) Then
MsgBox "This person exists."
Exit Sub
End If
Next bak
say = WorksheetFunction.CountA(Range("B1:B65500"))
'TextBox1.Value = say
Cells(say + 4, 4).Value = TextBox1.Value
Cells(say + 4, 2).Value = ComboBox1.Value
Cells(say + 4, 5).Value = ComboBox3.Value
Cells(say + 4, 3).Value = TextBox17.Value
Cells(say + 4, 6).Value = TextBox2.Value
Cells(say + 4, 7).Value = ComboBox4.Value
Cells(say + 4, 8).Value = TextBox3.Value
Cells(say + 4, 9).Value = TextBox4.Value
Cells(say + 4, 10).Value = TextBox5.Value
Cells(say + 4, 11).Value = TextBox6.Value
Cells(say + 4, 12).Value = TextBox7.Value
Cells(say + 4, 13).Value = TextBox8.Value
Cells(say + 4, 14).Value = TextBox9.Value
Cells(say + 4, 15).Value = TextBox10.Value
Cells(say + 4, 16).Value = TextBox11.Value
Cells(say + 4, 17).Value = TextBox12.Value
Cells(say + 4, 18).Value = TextBox13.Value
Cells(say + 4, 19).Value = TextBox14.Value
Cells(say + 4, 20).Value = TextBox15.Value
Cells(say + 4, 21).Value = TextBox16.Value
MsgBox "New entry was succesfull", vbInformation, "From " & Application.UserName

Range("A2:A65500").Select
Selection.Sort Key1:=Range("A2"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
'************************
Range("B5:U65500").Select
Selection.Sort Key1:=Range("B2"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Range("B2").Select '*********
TextBox1.Value = WorksheetFunction.Count(Range("A1:A65500")) + 1
CommandButton5_Click
ComboBox2_Change
ComboBox1.SetFocus
Unload UserForm3
UserForm3.Show
End Sub
Private Sub CommandButton13_Click()
On Error Resume Next
    If MsgBox("Close This Program?", vbYesNo, "Attention!") = vbNo Then Exit Sub
 
   
     MsgBox "The data are entered and the program will close", vbCritical
  Unload UserForm3
    Workbooks("Clever.xls").Save ''''''''''''''''''''''''''''''''''''
    Application.Visible = True
    Application.Quit
    
End Sub

Private Sub CommandButton2_Click()
Application.Visible = True
    Unload UserForm3
End Sub

Private Sub CommandButton3_Click()

End Sub

Private Sub CommandButton5_Click()
TextBox17.Value = ""
ComboBox1.Value = ""
    ComboBox2.Value = ""
    ComboBox3.Value = ""
    ComboBox4.Value = ""
    TextBox1.Value = ""
    TextBox2.Value = ""
    TextBox3.Value = ""
    TextBox4.Value = ""
    TextBox5.Value = ""
    TextBox6.Value = ""
    TextBox7.Value = ""
    TextBox8.Value = ""
    TextBox9.Value = ""
    TextBox10.Value = ""
    TextBox11.Value = ""
    TextBox12.Value = ""
    TextBox13.Value = ""
    TextBox14.Value = ""
    TextBox15.Value = ""
    TextBox16.Value = ""
    CommandButton5.Enabled = False
    CommandButton94.Enabled = False
CommandButton62.Enabled = False
CommandButton1.Enabled = True
    ComboBox1.SetFocus
End Sub







Private Sub CommandButton60_Click()
MsgBox "MyMessageBox"
End Sub




Private Sub CommandButton62_Click()
On Error Resume Next
Sheets("Telefon").Select
Dim MyRange As Range
    Dim bos As Range
    
    For Each bos In Range("B3:B" & WorksheetFunction.CountA(Range("B3:B65000")))
    
    Next bos
     If MsgBox("Gewählten Eintrag ändern?", vbQuestion + vbYesNo, "Attention") = vbYes Then
     If TextBox1 = "" Or ComboBox1 = "" Then
        MsgBox "Choose a new entry please"
    Else
    ActiveCell.Offset(0, 0).Value = ComboBox1.Value
   
   ActiveCell.Offset(0, 3).Value = ComboBox3.Value
    ActiveCell.Offset(0, 4).Value = TextBox2.Value
      ActiveCell.Offset(0, 2).Value = TextBox1.Value
     ActiveCell.Offset(0, 5).Value = ComboBox4.Value
      ActiveCell.Offset(0, 6).Value = TextBox3.Value
    ActiveCell.Offset(0, 7).Value = TextBox4.Value
    ActiveCell.Offset(0, 8).Value = TextBox5.Value
    ActiveCell.Offset(0, 9).Value = TextBox6.Value
    ActiveCell.Offset(0, 10).Value = TextBox7.Value
    ActiveCell.Offset(0, 11).Value = TextBox8.Value
    ActiveCell.Offset(0, 12).Value = TextBox9.Value
    ActiveCell.Offset(0, 13).Value = TextBox10.Value
    ActiveCell.Offset(0, 14).Value = TextBox11.Value
    ActiveCell.Offset(0, 15).Value = TextBox12.Value
    ActiveCell.Offset(0, 16).Value = TextBox13.Value
    ActiveCell.Offset(0, 17).Value = TextBox14.Value
    ActiveCell.Offset(0, 18).Value = TextBox15.Value
    ActiveCell.Offset(0, 19).Value = TextBox16.Value
    ActiveCell.Offset(0, 1).Value = TextBox17.Value
    MsgBox "" & ComboBox1.Value & " will be refreshed.", vbInformation, "Adress- und Telefonbook"
    ListBox1.Clear
    End If
    For Each MyRange In Sheets("Telefon").Range("B4:B" & Range("B65536").End(xlUp).Row)
         ListBox1.AddItem (MyRange)
         ListBox1.List(ListBox1.ListCount - 1, 1) = MyRange.Offset(0, 1).Value
         ListBox1.List(ListBox1.ListCount - 1, 2) = MyRange.Offset(0, 2).Value
         ListBox1.List(ListBox1.ListCount - 1, 3) = MyRange.Offset(0, 3).Value
    
    Next
     
     
 End If
   
End Sub

Private Sub CommandButton94_Click()
On Error Resume Next
Sheets("Telefon").Select
    If TextBox1.Text = "sira no" Then
    MsgBox "This ID can't be deleted", , "Deleting failure!!!"
    Exit Sub
    End If
     Dim say As Integer
    Dim i As Integer
    Dim bos As Range
    For Each bos In Range("B1:B" & WorksheetFunction.CountA(Range("B1:B65000")))
        If ComboBox1.Value = "" Or bos = "" Or ActiveCell = "" Then
            MsgBox "Bitte zuerst Suchen"
            Exit Sub
        End If
      Next bos
   If MsgBox("Delete this entry?", vbQuestion + vbYesNo, "Attention") = vbYes Then
   
 
     

 
   

    Range(ActiveCell.Offset(0, -1).Address(False, False) & ":" & ActiveCell.Offset(0, 20).Address(False, False)).Delete Shift:=xlUp
    MsgBox " " & ComboBox1.Value & " is deleted.", vbInformation, "Adress- und Telefonbook"
    say = WorksheetFunction.CountA(Range("A2:A65500"))
    For i = 1 To say
        Cells(i + 1, 1) = i
    Next i
    
    TextBox1.Value = WorksheetFunction.Count(Range("A1:A65500")) + 1
    CommandButton5_Click
    ComboBox2_Change
    ComboBox1.SetFocus
    Unload UserForm3
    UserForm3.Show
   End If
End Sub

Private Sub CommandButton95_Click()
Sheets("Telefon").Select
On Error Resume Next
    [aa4] = ComboBox1.Text
    [ac4] = ComboBox3.Text
    [ae4] = TextBox2.Text
    [ag4] = ComboBox4.Text
    [ac12] = TextBox3.Text
    [ac8] = TextBox4.Text
    [ae8] = TextBox5.Text
    [ag8] = TextBox6.Text
    [ae12] = TextBox7.Text
    [ag12] = TextBox8.Text
    [aa15] = TextBox9.Text
    [aa7] = TextBox10.Text
    [aa11] = TextBox11.Text
    [ac15] = TextBox12.Text
    [aa18] = TextBox13.Text
    [ae15] = TextBox14.Text
    [ag15] = TextBox15.Text
    [aa22] = TextBox16.Text
    
    Range("AF1:AL24").Select
    ActiveSheet.PageSetup.PrintArea = "$AA$1:$AG$24"
Application.ScreenUpdating = False
Application.Visible = True
Application.ScreenUpdating = True
UserForm3.Hide

'
Sheets(Array("Telefon")).PrintPreview
Application.ScreenUpdating = False
Application.Visible = False
Application.ScreenUpdating = True
Sheets("Telefon").Select
UserForm3.Show
End Sub






Private Sub Label8_Click()

End Sub

Private Sub ListBox1_Click()
On Error Resume Next
Sheets("Telefon").Select
Dim x As Integer
x = Sheets("Telefon").Range("B:B").Cells.Find(what:=ListBox1, LookIn:=xlValues).Row
ComboBox1.Value = ListBox1
  Dim MyRange As Range
  Dim bak As Range
    For Each bak In Range("B1:B" & WorksheetFunction.CountA(Range("B1:B65000")))
        If StrConv(bak.Value, vbUpperCase) = StrConv(ComboBox1.Value, vbUpperCase) Then
           bak.Select
            TextBox17.Value = ActiveCell.Offset(0, 1).Value
            ComboBox3.Value = ActiveCell.Offset(0, 3).Value
            TextBox2.Value = ActiveCell.Offset(0, 4).Value
            ComboBox4.Value = ActiveCell.Offset(0, 5).Value
            TextBox1.Value = ActiveCell.Offset(0, 2).Value
            TextBox4.Value = ActiveCell.Offset(0, 7).Value
            TextBox5.Value = ActiveCell.Offset(0, 8).Value
            TextBox6.Value = ActiveCell.Offset(0, 9).Value
            TextBox7.Value = ActiveCell.Offset(0, 10).Value
            TextBox3.Value = ActiveCell.Offset(0, 6).Value
            TextBox8.Value = ActiveCell.Offset(0, 11).Value
            TextBox9.Value = ActiveCell.Offset(0, 12).Value
            TextBox10.Value = ActiveCell.Offset(0, 13).Value
            TextBox11.Value = ActiveCell.Offset(0, 14).Value
            TextBox12.Value = ActiveCell.Offset(0, 15).Value
            TextBox13.Value = ActiveCell.Offset(0, 16).Value
            TextBox14.Value = ActiveCell.Offset(0, 17).Value
            TextBox15.Value = ActiveCell.Offset(0, 18).Value
            TextBox16.Value = ActiveCell.Offset(0, 19).Value
            ListBox1.Clear
            For Each MyRange In Sheets("Telefon").Range("B4:B" & Range("B65536").End(xlUp).Row)
                ListBox1.AddItem (MyRange)
                ListBox1.List(ListBox1.ListCount - 1, 1) = MyRange.Offset(0, 1).Value
                ListBox1.List(ListBox1.ListCount - 1, 2) = MyRange.Offset(0, 2).Value
                ListBox1.List(ListBox1.ListCount - 1, 3) = MyRange.Offset(0, 3).Value
            Next
             CommandButton5.Enabled = True
    CommandButton94.Enabled = True
CommandButton62.Enabled = True
CommandButton1.Enabled = False
            Exit Sub
        End If
    Next bak
    CommandButton5.Enabled = True
    CommandButton94.Enabled = True
CommandButton62.Enabled = True
CommandButton1.Enabled = False
    ComboBox2.SetFocus



End Sub



Private Sub TextBox3_Change()
If Len(TextBox3.Text) >= 15 Then TextBox3 = Left(TextBox3, 15)
If Len(TextBox3.Text) < 10 Then
TextBox3 = Replace(TextBox3, " ", "")
Else
TextBox3.Text = Format(TextBox3, "(###) ###-##-##")
End If
End Sub



Private Sub TextBox3_Exit(ByVal Cancel As MSForms.ReturnBoolean)
TextBox3 = Format(TextBox3, "(###) ###-##-##")
End Sub

Private Sub TextBox4_Change()
If Len(TextBox4.Text) >= 15 Then TextBox4 = Left(TextBox4, 15)
If Len(TextBox4.Text) < 10 Then
TextBox4 = Replace(TextBox4, " ", "")
Else
TextBox4.Text = Format(TextBox4, "(###) ###-##-##")
End If
End Sub

Private Sub TextBox4_Exit(ByVal Cancel As MSForms.ReturnBoolean)
TextBox4 = Format(TextBox4, "(###) ###-##-##")
End Sub

Private Sub TextBox5_Change()
If Len(TextBox5.Text) >= 15 Then TextBox5 = Left(TextBox5, 15)
If Len(TextBox5.Text) < 10 Then
TextBox5 = Replace(TextBox5, " ", "")
Else
TextBox5.Text = Format(TextBox5, "(###) ###-##-##")
End If
End Sub

Private Sub TextBox5_Exit(ByVal Cancel As MSForms.ReturnBoolean)
TextBox5 = Format(TextBox5, "(###) ###-##-##")
End Sub

Private Sub TextBox6_Change()
If Len(TextBox6.Text) >= 15 Then TextBox6 = Left(TextBox6, 15)
If Len(TextBox6.Text) < 10 Then
TextBox6 = Replace(TextBox6, " ", "")
Else
TextBox6.Text = Format(TextBox6, "(###) ###-##-##")
End If
End Sub

Private Sub TextBox6_Exit(ByVal Cancel As MSForms.ReturnBoolean)
TextBox6 = Format(TextBox6, "(###) ###-##-##")
End Sub

Private Sub TextBox7_Change()
If Len(TextBox7.Text) >= 15 Then TextBox7 = Left(TextBox7, 15)
If Len(TextBox7.Text) < 10 Then
TextBox7 = Replace(TextBox7, " ", "")
Else
TextBox7.Text = Format(TextBox7, "(###) ###-##-##")
End If
End Sub

Private Sub TextBox7_Exit(ByVal Cancel As MSForms.ReturnBoolean)
TextBox7 = Format(TextBox7, "(###) ###-##-##")
End Sub

Private Sub UserForm_Initialize()
On Error Resume Next
Dim MyRange As Range
Dim noA As Integer
noA = WorksheetFunction.CountA(Sheets("Telefon").Range("B:B"))
For Each MyRange In Sheets("Telefon").Range("B4:B" & 3 + noA)
If Left(LCase(MyRange), Len(ComboBox2)) = LCase(ComboBox2) Then ListBox1.AddItem (MyRange)
Next

ComboBox1.SetFocus
CommandButton5.Enabled = False
CommandButton94.Enabled = False
CommandButton62.Enabled = False
ComboBox3.RowSource = "Telefon!AO5:AO8"
ComboBox4.RowSource = "Telefon!AQ5:AQ100"
End Sub

Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
    If CloseMode <> 1 Then Cancel = True
End Sub
 
Upvote 0
You didn't need to post the entire code.

If you just explain on words what you want to do it should be enough, to start with anyway.

Back to the form.

Only managed to take a quick look but from your latest post it sounds like quite a few things need changed.

What you want in the listbox is quite different.

Also I'm not sure what you want to do with the postal/zip codes.

What's an 'optionbox'?

By the way, can you change the form or does it need to be kept as it is?

If you can there are probably a couple of things that could be tidied up.
 
Upvote 0

Forum statistics

Threads
1,224,560
Messages
6,179,520
Members
452,921
Latest member
BBQKING

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