Modificar datos de un listbox en vba con matriz

Me gustaría aclarar una duda si es posible realizar y/o modificar datos de una columna sin que se tenga que registrar en una hoja primero para poder visualizar el dato en un listbox llevo días tratando de realizar esta consulta no lo e logrado lo que me gustaría ver en el listbox sin insertar en una hoja el dato modificado de una caja de texto, que quiero decir
los datos están cargados en el listbox con un control de búsqueda tipo texto carga el listbox con otro textbox quiero colocar un dato numérico y este a su vez cambie la columna 4 del listbox realizando una suma o la operación matemática que quiera implementar y se visualice en el listbox es decir que en la columna 4 del list esta el dato 45 y en el control de texto coloque 10 el listbox muestre el resultado 45+10 =resultado todo esto preparado para una posible registro en una hoja pero mi pregunta inicial es si lo puedo hacer todo realizado en función de matriz gracias!

Option Explicit
Dim a As Variant
Private Sub btn_Click()
Dim txt1 As String, txt2 As String, txt3 As String
  Dim b As Variant
  Dim i As Long, j As Long, k As Long
a = Sheets(Hoja1.Name).Range("A1:XP" & Sheets(Hoja1.Name).Range("A" & Rows.Count).End(3).Row).Value
 ReDim b(1 To UBound(a, 1) * UBound(a, 2), 1 To 4)
  ' ReDim b(1 To UBound(a, 1), 1 To UBound(a, 2))
ListBox1.Clear
  For i = 1 To UBound(a, 1)
    If TextBox2.Value = "" Then txt2 = a(i, 2) Else txt2 = TextBox2.Value
    'If LCase(a(i, 2)) Like "*" & LCase(txt2) & "*" Then
      j = j + 1
      For k = 5 To UBound(a, 2)
           '''b(j, 4) = a(i, k)
        If a(i, k) > 0 Then
 ''b(j, i) = a(i, k) + txt2
           b(j, 1) = a(i, 2)
           'b(k, 2) = a(i, 3)
           b(j, 4) = (a(i, k)) '+ txt2
           b(j, 3) = a(1, k)
         j = j + 1
        End If
'        b(j, k) = a(i, k)
     Next
   ' End If
 Next i
 If j > 0 Then ListBox1.List = b
End Sub
Private Sub TextBox1_Change()
Dim txt1 As String, txt2 As String, txt3 As String
  Dim b As Variant
  Dim i As Long, j As Long, k As Long
a = Sheets(Hoja1.Name).Range("A1:XP" & Sheets(Hoja1.Name).Range("A" & Rows.Count).End(3).Row).Value
 ReDim b(1 To UBound(a, 1) * UBound(a, 2), 1 To 4)
  ' ReDim b(1 To UBound(a, 1), 1 To UBound(a, 2))
ListBox1.Clear
  For i = 1 To UBound(a, 1)
    If TextBox1.Value = "" Then txt1 = a(i, 2) Else txt1 = TextBox1.Value
    If LCase(a(i, 2)) Like "*" & LCase(txt1) & "*" Then
      j = j + 1
      For k = 5 To UBound(a, 2)
       ''b(j, k) = a(i, k)
        If a(i, k) > 0 Then
           b(j, 1) = a(i, 2)
           'b(k, 2) = a(i, 3)
           b(j, 4) = a(i, k)
           b(j, 3) = a(1, k)
         j = j + 1
        End If
'        b(j, k) = a(i, k)
     Next
    End If
 Next i
 If j > 0 Then ListBox1.List = b
End Sub
Private Sub UserForm_Initialize()
Dim txt1 As String, txt2 As String, txt3 As String
  Dim b As Variant
  Dim i As Long, j As Long, k As Long
'a = Range("A3").CurrentRegion.Value
''ListBox1.ColumnCount = UBound(a, 1)
a = Sheets(Hoja1.Name).Range("A2:XP" & Sheets(Hoja1.Name).Range("A" & Rows.Count).End(3).Row).Value ' se carga todo en una matriz
'''Range("A" & Rows.Count).End(xlUp).Row
'ListBox1.ColumnCount = UBound(a, 2)
  With ListBox1
 .List = a ' la matriz queda cargada para mostrar
 .ColumnCount = 5 ''''UBound(a, 1) '"numero de  ccolumnas de la cantidad que hay en la matriz" numero de columna de la hojas amostrar puedo colacr el num de la columna
 .ColumnWidths = "50pt;80pt;80pt;50pt" 'columna 0  no se muestre y segunda columna con dimencion 20
 .ColumnHeads = True
End With
End Sub

Añade tu respuesta

Haz clic para o