How to add a TextBox dynamically using VB

-2

How to add a TextBox dynamically whenever the Userform (Combination Box or Data Validation List) is equal to "Outro (Especificar)" , using VB ?

I'mlost,I'mnewatmakingmacrosandforms,usingVB.^^'

IwasdoingwithDataValidation,List.

SubOutro()''OutroMacrocoluna=1linha=1WhileCells(linha,coluna).Value<>""
    Application.Visible = False 'torna invisível a aplicação Excel
    valorCelula = Format(Cells(linha, coluna).Value, 2)
    'If valorCelula <> Cells(linha, coluna).Value Then
    '    Cells(linha, coluna).Value = valorCelula
    'End If
    linha = linha + 1
    With Selection.Font
            .Color = -16776961
            .TintAndShade = 0
        End With
        Selection.Font.Bold = True
        Range("G3").Select
        ActiveSheet.OLEObjects.Add(ClassType:="Forms.TextBox.1", Link:=False, _
           DisplayAsIcon:=False, Left:=497.25, Top:=36, Width:=66.75, Height:= _
           10.5).Select
Wend
End Sub
    
asked by anonymous 02.08.2017 / 21:25

1 answer

0

Right click on the ComboBox and go to:

ClickNewonthescreenthatappears:

IusedthiscodeinsubDropdown1_Alteração

SetoTB=ActiveSheet.OLEObjects.Add(ClassType:="Forms.TextBox.1")
Set cell = ActiveSheet.Range("C2")
With oTB
.Name = "MyTB"
.LinkedCell = "$C$2"
.Left = cell.Left
.Top = cell.Top
.Width = cell.Width
.Height = cell.Height
.Object.BackColor = RGB(204, 204, 255)
.Object.ForeColor = RGB(0, 0, 255)
.Object.Text = "Texto"
End With
    
03.08.2017 / 23:42