.
Antes de seguir recomiendo leer un excelente libro sobre Excel que te ayudará operar las planillas u hojas de cálculo, haz click acá, si quieres aprender sobre Excel, en inglés, entonces debes hacer click here. Si lo que necesitas es aprender o profundizar sobre la programación de macros con VBA este es unos de los mejores cursos on line que he visto en internet.
También se pueden recorrer los datos e ir incorporando a cada uno de los productos del listado con el comando Add Item.
if (payload.eventType == ‘subscribe’) {
// Add code to handle subscribe event.
} else if (payload.eventType == ‘unsubscribe’) {
// Add code to handle unsubscribe event.
}
if (window.console) { // for debugging only
window.console.log(‘YT event: ‘, payload);
}
}
Código que se inserta en un móduloSub muestra1()
UserForm1.Show
End Sub
Código que se inserta en un formulario
Private Sub CommandButton1_Click()
Unload Me
End Sub
Private Sub TextBox1_Change()
‘On Error Resume Next
‘Dim articulos As Worksheet
‘Set articulos = Sheets(«ARTI»)
‘uf = articulos.Range(«B» & Rows.Count).End(xlUp).Row
‘uc = articulos.Cells(9, Columns.Count).End(xlToLeft).Address
‘wc = Mid(uc, InStr(uc, «$») + 1, InStr(2, uc, «$») – 2)
‘For Each arti In articulos.Range(«D21:» & wc & uf)
‘ If arti Like TextBox1 & «*» Then
‘ ListBox1 = Clear
‘ ListBox1.AddItem arti
‘ ListBox1.List(ListBox1.ListCount – 1, 1) = arti.Row ‘Fila
‘ a = ListBox1.ListCount
‘ ListBox1.AddItem
‘ ListBox1.List(a, 0) = articulos.Cells(arti, 2)
‘ ListBox1.List(a, 1) = b.Cells(fila, 3)
‘ ListBox1.List(a, 2) = b.Cells(fila, 4)
‘ ListBox1.List(a, 3) = b.Cells(fila, 5)
‘ ListBox1.List(a, 4) = b.Cells(fila, 6)
‘ ListBox1.List(a, 5) = b.Cells(fila, 7)
‘ ListBox1.List(a, 6) = b.Cells(fila, 8)
‘ ListBox1.List(a, 7) = b.Cells(fila, 9)
‘ ListBox1.List(a, 8) = b.Cells(fila, 10)
‘ ListBox1.List(a, 9) = b.Cells(fila, 11)
‘ End If
‘Next arti
‘Me.ListBox1 = Clear
uf = Sheets(«ARTI»).Range(«B» & Rows.Count).End(xlUp).Row
If Trim(TextBox1.Value) = «» Then
Me.ListBox1.List() = Sheets(«ARTI»).Range(«B9:J» & Sheets(«ARTI»).Range(«A» & Rows.Count).End(xlUp).Row).Value
Me.ListBox1.RowSource = «ARTI!B21:K» & uf
Exit Sub
End If
Sheets(«ARTI»).AutoFilterMode = False
Me.ListBox1 = Clear
Me.ListBox1.RowSource = Clear
For i = 10 To uf
strg = Sheets(«ARTI»).Cells(i, 3).Value
If strg Like UCase(TextBox1.Value) & «*» Then
Me.ListBox1.AddItem Sheets(«ARTI»).Cells(i, 2)
Me.ListBox1.List(Me.ListBox1.ListCount – 1, 1) = Sheets(«ARTI»).Cells(i, 3)
Me.ListBox1.List(Me.ListBox1.ListCount – 1, 2) = Sheets(«ARTI»).Cells(i, 4)
Me.ListBox1.List(Me.ListBox1.ListCount – 1, 3) = Sheets(«ARTI»).Cells(i, 5)
Me.ListBox1.List(Me.ListBox1.ListCount – 1, 4) = Sheets(«ARTI»).Cells(i, 6)
Me.ListBox1.List(Me.ListBox1.ListCount – 1, 5) = Sheets(«ARTI»).Cells(i, 7)
Me.ListBox1.List(Me.ListBox1.ListCount – 1, 6) = Sheets(«ARTI»).Cells(i, 8)
Me.ListBox1.List(Me.ListBox1.ListCount – 1, 7) = Sheets(«ARTI»).Cells(i, 9)
Me.ListBox1.List(Me.ListBox1.ListCount – 1, 8) = Sheets(«ARTI»).Cells(i, 10)
Me.ListBox1.List(Me.ListBox1.ListCount – 1, 9) = Sheets(«ARTI»).Cells(i, 11)
End If
Next i
Me.ListBox1.ColumnWidths = «50 pt;180 pt;180 pt;60 pt;40 pt;40 pt;40 pt;40 pt;40 pt;40 pt»
Exit Sub
Errores:
MsgBox «No se encuentra.», vbExclamation, «EXCELeINFO»
End Sub
Private Sub TextBox2_Change()
‘On Error Resume Next
‘Dim articulos As Worksheet
‘Set articulos = Sheets(«ARTI»)
‘uf = articulos.Range(«B» & Rows.Count).End(xlUp).Row
‘uc = articulos.Cells(9, Columns.Count).End(xlToLeft).Address
‘wc = Mid(uc, InStr(uc, «$») + 1, InStr(2, uc, «$») – 2)
‘For Each arti In articulos.Range(«D21:» & wc & uf)
‘ If arti Like TextBox1 & «*» Then
‘ ListBox1 = Clear
‘ ListBox1.AddItem arti
‘ ListBox1.List(ListBox1.ListCount – 1, 1) = arti.Row ‘Fila
‘ a = ListBox1.ListCount
‘ ListBox1.AddItem
‘ ListBox1.List(a, 0) = articulos.Cells(arti, 2)
‘ ListBox1.List(a, 1) = b.Cells(fila, 3)
‘ ListBox1.List(a, 2) = b.Cells(fila, 4)
‘ ListBox1.List(a, 3) = b.Cells(fila, 5)
‘ ListBox1.List(a, 4) = b.Cells(fila, 6)
‘ ListBox1.List(a, 5) = b.Cells(fila, 7)
‘ ListBox1.List(a, 6) = b.Cells(fila, 8)
‘ ListBox1.List(a, 7) = b.Cells(fila, 9)
‘ ListBox1.List(a, 8) = b.Cells(fila, 10)
‘ ListBox1.List(a, 9) = b.Cells(fila, 11)
‘ End If
‘Next arti
‘Me.ListBox1 = Clear
‘Me.ListBox1 = Clear
‘Me.ListBox1.RowSource = Clear
uf = Sheets(«ARTI»).Range(«B» & Rows.Count).End(xlUp).Row
If Trim(TextBox2.Value) = «» Then
Me.ListBox1.List() = Sheets(«ARTI»).Range(«B9:J» & Sheets(«ARTI»).Range(«A» & Rows.Count).End(xlUp).Row).Value
Me.ListBox1.RowSource = «ARTI!B21:K» & uf
Exit Sub
End If
Sheets(«ARTI»).AutoFilterMode = False
Me.ListBox1 = Clear
Me.ListBox1.RowSource = Clear
For i = 10 To uf
strg = Sheets(«ARTI»).Cells(i, 4).Value
If strg Like UCase(TextBox2.Value) & «*» Then
Me.ListBox1.AddItem Sheets(«ARTI»).Cells(i, 2)
Me.ListBox1.List(Me.ListBox1.ListCount – 1, 1) = Sheets(«ARTI»).Cells(i, 3)
Me.ListBox1.List(Me.ListBox1.ListCount – 1, 2) = Sheets(«ARTI»).Cells(i, 4)
Me.ListBox1.List(Me.ListBox1.ListCount – 1, 3) = Sheets(«ARTI»).Cells(i, 5)
Me.ListBox1.List(Me.ListBox1.ListCount – 1, 4) = Sheets(«ARTI»).Cells(i, 6)
Me.ListBox1.List(Me.ListBox1.ListCount – 1, 5) = Sheets(«ARTI»).Cells(i, 7)
Me.ListBox1.List(Me.ListBox1.ListCount – 1, 6) = Sheets(«ARTI»).Cells(i, 8)
Me.ListBox1.List(Me.ListBox1.ListCount – 1, 7) = Sheets(«ARTI»).Cells(i, 9)
Me.ListBox1.List(Me.ListBox1.ListCount – 1, 8) = Sheets(«ARTI»).Cells(i, 10)
Me.ListBox1.List(Me.ListBox1.ListCount – 1, 9) = Sheets(«ARTI»).Cells(i, 11)
End If
Next i
Me.ListBox1.ColumnWidths = «50 pt;180 pt;180 pt;60 pt;40 pt;40 pt;40 pt;40 pt;40 pt;40 pt»
Exit Sub
Errores:
MsgBox «No se encuentra.», vbExclamation, «EXCELeINFO»
End Sub
Private Sub Frame2_Click()
End Sub
Private Sub UserForm_Initialize()
Dim fila As Long
On Error Resume Next
Application.DisplayAlerts = False
Application.ScreenUpdating = False
Set a = Sheets(«Hoja1»)
uf = a.Range(«B» & Rows.Count).End(xlUp).Row
uc = a.Cells(9, Columns.Count).End(xlToLeft).Address
wc = Mid(uc, InStr(uc, «$») + 1, InStr(2, uc, «$») – 2)
With Me.ListBox1
.ColumnCount = 10
.ColumnWidths = «50 pt;180 pt;180 pt;60 pt;40 pt;40 pt;40 pt;40 pt;40 pt;40 pt»
.RowSource = «Hoja1!A2:» & wc & uf
End With
With Me.ListBox2
.ColumnCount = 10
.ColumnWidths = «50 pt;180 pt;180 pt;60 pt;40 pt;40 pt;40 pt;40 pt;40 pt;40 pt»
.RowSource = «Hoja1!A2:» & wc & uf
.List() = a.Range(«A2:H» & uf)
End With
‘ Me.ListBox1.List() = Sheets(«ARTI»).Range(«B9:J» & Sheets(«ARTI»).Range(«A» & Rows.Count).End(xlUp).Row).Value
‘Me.ListBox1.ColumnCount = 10
‘Me.ListBox1.RowSource = «ARTI!B21:» & wc & uf
‘ListBox1.Clear
fila = 2
While a.Cells(fila, 1) <> Empty
aa = ListBox3.ListCount
ListBox3.AddItem
ListBox3.List(aa, 0) = a.Cells(fila, 1)
ListBox3.List(aa, 1) = a.Cells(fila, 2)
ListBox3.List(aa, 2) = a.Cells(fila, 3)
ListBox3.List(aa, 3) = a.Cells(fila, 4)
ListBox3.List(aa, 4) = a.Cells(fila, 5)
ListBox3.List(aa, 5) = a.Cells(fila, 6)
ListBox3.List(aa, 6) = a.Cells(fila, 7)
ListBox3.List(aa, 7) = a.Cells(fila, 8)
fila = fila + 1
Wend
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
On Error GoTo Fin
If CloseMode <> 1 Then Cancel = True
Fin:
End Sub
Sub muestra1()
UserForm1.Show
End Sub
Unload Me
End Sub
Private Sub TextBox1_Change()
‘On Error Resume Next
‘Dim articulos As Worksheet
‘Set articulos = Sheets(«ARTI»)
‘uf = articulos.Range(«B» & Rows.Count).End(xlUp).Row
‘uc = articulos.Cells(9, Columns.Count).End(xlToLeft).Address
‘wc = Mid(uc, InStr(uc, «$») + 1, InStr(2, uc, «$») – 2)
‘For Each arti In articulos.Range(«D21:» & wc & uf)
‘ If arti Like TextBox1 & «*» Then
‘ ListBox1 = Clear
‘ ListBox1.AddItem arti
‘ ListBox1.List(ListBox1.ListCount – 1, 1) = arti.Row ‘Fila
‘ a = ListBox1.ListCount
‘ ListBox1.AddItem
‘ ListBox1.List(a, 0) = articulos.Cells(arti, 2)
‘ ListBox1.List(a, 1) = b.Cells(fila, 3)
‘ ListBox1.List(a, 2) = b.Cells(fila, 4)
‘ ListBox1.List(a, 3) = b.Cells(fila, 5)
‘ ListBox1.List(a, 4) = b.Cells(fila, 6)
‘ ListBox1.List(a, 5) = b.Cells(fila, 7)
‘ ListBox1.List(a, 6) = b.Cells(fila, 8)
‘ ListBox1.List(a, 7) = b.Cells(fila, 9)
‘ ListBox1.List(a, 8) = b.Cells(fila, 10)
‘ ListBox1.List(a, 9) = b.Cells(fila, 11)
‘ End If
‘Next arti
‘Me.ListBox1 = Clear
uf = Sheets(«ARTI»).Range(«B» & Rows.Count).End(xlUp).Row
If Trim(TextBox1.Value) = «» Then
Me.ListBox1.List() = Sheets(«ARTI»).Range(«B9:J» & Sheets(«ARTI»).Range(«A» & Rows.Count).End(xlUp).Row).Value
Me.ListBox1.RowSource = «ARTI!B21:K» & uf
Exit Sub
End If
Sheets(«ARTI»).AutoFilterMode = False
Me.ListBox1 = Clear
Me.ListBox1.RowSource = Clear
For i = 10 To uf
strg = Sheets(«ARTI»).Cells(i, 3).Value
If strg Like UCase(TextBox1.Value) & «*» Then
Me.ListBox1.AddItem Sheets(«ARTI»).Cells(i, 2)
Me.ListBox1.List(Me.ListBox1.ListCount – 1, 1) = Sheets(«ARTI»).Cells(i, 3)
Me.ListBox1.List(Me.ListBox1.ListCount – 1, 2) = Sheets(«ARTI»).Cells(i, 4)
Me.ListBox1.List(Me.ListBox1.ListCount – 1, 3) = Sheets(«ARTI»).Cells(i, 5)
Me.ListBox1.List(Me.ListBox1.ListCount – 1, 4) = Sheets(«ARTI»).Cells(i, 6)
Me.ListBox1.List(Me.ListBox1.ListCount – 1, 5) = Sheets(«ARTI»).Cells(i, 7)
Me.ListBox1.List(Me.ListBox1.ListCount – 1, 6) = Sheets(«ARTI»).Cells(i, 8)
Me.ListBox1.List(Me.ListBox1.ListCount – 1, 7) = Sheets(«ARTI»).Cells(i, 9)
Me.ListBox1.List(Me.ListBox1.ListCount – 1, 8) = Sheets(«ARTI»).Cells(i, 10)
Me.ListBox1.List(Me.ListBox1.ListCount – 1, 9) = Sheets(«ARTI»).Cells(i, 11)
End If
Next i
Me.ListBox1.ColumnWidths = «50 pt;180 pt;180 pt;60 pt;40 pt;40 pt;40 pt;40 pt;40 pt;40 pt»
Exit Sub
Errores:
MsgBox «No se encuentra.», vbExclamation, «EXCELeINFO»
End Sub
Private Sub TextBox2_Change()
‘On Error Resume Next
‘Dim articulos As Worksheet
‘Set articulos = Sheets(«ARTI»)
‘uf = articulos.Range(«B» & Rows.Count).End(xlUp).Row
‘uc = articulos.Cells(9, Columns.Count).End(xlToLeft).Address
‘wc = Mid(uc, InStr(uc, «$») + 1, InStr(2, uc, «$») – 2)
‘For Each arti In articulos.Range(«D21:» & wc & uf)
‘ If arti Like TextBox1 & «*» Then
‘ ListBox1 = Clear
‘ ListBox1.AddItem arti
‘ ListBox1.List(ListBox1.ListCount – 1, 1) = arti.Row ‘Fila
‘ a = ListBox1.ListCount
‘ ListBox1.AddItem
‘ ListBox1.List(a, 0) = articulos.Cells(arti, 2)
‘ ListBox1.List(a, 1) = b.Cells(fila, 3)
‘ ListBox1.List(a, 2) = b.Cells(fila, 4)
‘ ListBox1.List(a, 3) = b.Cells(fila, 5)
‘ ListBox1.List(a, 4) = b.Cells(fila, 6)
‘ ListBox1.List(a, 5) = b.Cells(fila, 7)
‘ ListBox1.List(a, 6) = b.Cells(fila, 8)
‘ ListBox1.List(a, 7) = b.Cells(fila, 9)
‘ ListBox1.List(a, 8) = b.Cells(fila, 10)
‘ ListBox1.List(a, 9) = b.Cells(fila, 11)
‘ End If
‘Next arti
‘Me.ListBox1 = Clear
‘Me.ListBox1 = Clear
‘Me.ListBox1.RowSource = Clear
uf = Sheets(«ARTI»).Range(«B» & Rows.Count).End(xlUp).Row
If Trim(TextBox2.Value) = «» Then
Me.ListBox1.List() = Sheets(«ARTI»).Range(«B9:J» & Sheets(«ARTI»).Range(«A» & Rows.Count).End(xlUp).Row).Value
Me.ListBox1.RowSource = «ARTI!B21:K» & uf
Exit Sub
End If
Sheets(«ARTI»).AutoFilterMode = False
Me.ListBox1 = Clear
Me.ListBox1.RowSource = Clear
For i = 10 To uf
strg = Sheets(«ARTI»).Cells(i, 4).Value
If strg Like UCase(TextBox2.Value) & «*» Then
Me.ListBox1.AddItem Sheets(«ARTI»).Cells(i, 2)
Me.ListBox1.List(Me.ListBox1.ListCount – 1, 1) = Sheets(«ARTI»).Cells(i, 3)
Me.ListBox1.List(Me.ListBox1.ListCount – 1, 2) = Sheets(«ARTI»).Cells(i, 4)
Me.ListBox1.List(Me.ListBox1.ListCount – 1, 3) = Sheets(«ARTI»).Cells(i, 5)
Me.ListBox1.List(Me.ListBox1.ListCount – 1, 4) = Sheets(«ARTI»).Cells(i, 6)
Me.ListBox1.List(Me.ListBox1.ListCount – 1, 5) = Sheets(«ARTI»).Cells(i, 7)
Me.ListBox1.List(Me.ListBox1.ListCount – 1, 6) = Sheets(«ARTI»).Cells(i, 8)
Me.ListBox1.List(Me.ListBox1.ListCount – 1, 7) = Sheets(«ARTI»).Cells(i, 9)
Me.ListBox1.List(Me.ListBox1.ListCount – 1, 8) = Sheets(«ARTI»).Cells(i, 10)
Me.ListBox1.List(Me.ListBox1.ListCount – 1, 9) = Sheets(«ARTI»).Cells(i, 11)
End If
Next i
Me.ListBox1.ColumnWidths = «50 pt;180 pt;180 pt;60 pt;40 pt;40 pt;40 pt;40 pt;40 pt;40 pt»
Exit Sub
Errores:
MsgBox «No se encuentra.», vbExclamation, «EXCELeINFO»
End Sub
Private Sub Frame2_Click()
End Sub
Private Sub UserForm_Initialize()
Dim fila As Long
On Error Resume Next
Application.DisplayAlerts = False
Application.ScreenUpdating = False
Set a = Sheets(«Hoja1»)
uf = a.Range(«B» & Rows.Count).End(xlUp).Row
uc = a.Cells(9, Columns.Count).End(xlToLeft).Address
wc = Mid(uc, InStr(uc, «$») + 1, InStr(2, uc, «$») – 2)
With Me.ListBox1
.ColumnCount = 10
.ColumnWidths = «50 pt;180 pt;180 pt;60 pt;40 pt;40 pt;40 pt;40 pt;40 pt;40 pt»
.RowSource = «Hoja1!A2:» & wc & uf
End With
With Me.ListBox2
.ColumnCount = 10
.ColumnWidths = «50 pt;180 pt;180 pt;60 pt;40 pt;40 pt;40 pt;40 pt;40 pt;40 pt»
.RowSource = «Hoja1!A2:» & wc & uf
.List() = a.Range(«A2:H» & uf)
End With
‘ Me.ListBox1.List() = Sheets(«ARTI»).Range(«B9:J» & Sheets(«ARTI»).Range(«A» & Rows.Count).End(xlUp).Row).Value
‘Me.ListBox1.ColumnCount = 10
‘Me.ListBox1.RowSource = «ARTI!B21:» & wc & uf
‘ListBox1.Clear
fila = 2
While a.Cells(fila, 1) <> Empty
aa = ListBox3.ListCount
ListBox3.AddItem
ListBox3.List(aa, 0) = a.Cells(fila, 1)
ListBox3.List(aa, 1) = a.Cells(fila, 2)
ListBox3.List(aa, 2) = a.Cells(fila, 3)
ListBox3.List(aa, 3) = a.Cells(fila, 4)
ListBox3.List(aa, 4) = a.Cells(fila, 5)
ListBox3.List(aa, 5) = a.Cells(fila, 6)
ListBox3.List(aa, 6) = a.Cells(fila, 7)
ListBox3.List(aa, 7) = a.Cells(fila, 8)
fila = fila + 1
Wend
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
On Error GoTo Fin
If CloseMode <> 1 Then Cancel = True
Fin:
End Sub
.
If this post was helpful INVITE ME A COFFEE and so help keep up the page, CLICK to download free example.
Si te gustó por favor compártelo con tus amigos
If you liked please share it with your friends