• Privacywetgeving
    Het is bij Helpmij.nl niet toegestaan om persoonsgegevens in een voorbeeld te plaatsen. Alle voorbeelden die persoonsgegevens bevatten zullen zonder opgaaf van reden verwijderd worden. In de vraag zal specifiek vermeld moeten worden dat het om fictieve namen gaat.

Textbox tekst automatisch invullen als cel leeg is

Status
Niet open voor verdere reacties.

marcel31281

Gebruiker
Lid geworden
30 okt 2015
Berichten
391
Excel toppers,

In textbox1 van mijn userform wil ik graag de tekst die eerder ingevuld is weer terughalen door te verwijzen naar de actieve cel, echter als actieve cel leeg is moet er in textbox1 standaard "geen bijzonderheden" komen te staan.

Deel 1 lukt met de volgende code

Code:
Private Sub userform_activate()
  With Sheets("-OVERZICHT-")
        Dim num As Integer
        num = ActiveCell.Row
        TextBox2.Value = .Cells(num, 7).Value 'serienummer'
        TextBox3.Value = .Cells(num, 9).Value
        TextBox1.Value = .Cells(num, 11).Value 'bijzonderheden
        TextBox4.Value = .Cells(num, 14).Value 'etage
        TextBox5.Value = .Cells(num, 15).Value 'naam afdeling
        ComboBox1.Value = .Cells(num, 12).Value
        ComboBox9.Value = .Cells(num, 13).Value
End With
End Sub

Alvast bedankt,
 
probeer eens zo
Code:
Private Sub userform_activate()
Dim num As Integer
Dim varTxt As Variant
 
  
With Sheets("-OVERZICHT-")
    num = ActiveCell.Row
    varTxt = .Cells(num, 11).Value 'bijzonderheden
    If varTxt = "" Then varTxt = "Geen bijzonderheden"
    
    
    TextBox2.Value = .Cells(num, 7).Value 'serienummer'
    TextBox3.Value = .Cells(num, 9).Value
    TextBox1.Value = varTxt
    TextBox4.Value = .Cells(num, 14).Value 'etage
    TextBox5.Value = .Cells(num, 15).Value 'naam afdeling
    ComboBox1.Value = .Cells(num, 12).Value
    ComboBox9.Value = .Cells(num, 13).Value
End With


End Sub
 
Code:
Private Sub userform_Initialize()
  sn = activecell.offset(,1 - activecell.column).resize(,15)

  for j=1 to 5
    Me("TextBox" & j)=sn(1,choose(j,11,7,9,14,15))
  next
  ComboBox1.Value = sn(1, 12)
  ComboBox9.Value = sn(1, 13)
End Sub
 
Status
Niet open voor verdere reacties.
Terug
Bovenaan Onderaan