Saltar al contenido
View in the app

A better way to browse. Learn more.

Ayuda Excel

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Insertar a Excel un Combobox y textbox

publicado

Hola necesito ayuda estoy haciendo un proyecto y al momento de Insertar me sale un error, tengo en la hoja1 unos datos que se cargar en Combobox y rellena el textbos que tengo y estos datos los quiero ingresar en la hoja2 pero me sale un error les copio los codigos.

Private Sub ComboBox1_Change()

Hoja1.Select

TextBox1.Value = Cells(ComboBox1.ListIndex + 1, 1).Offset(0, 1) aqui es donde me sale el error al momento de insertar

Range("a2").Select

ActiveCell.FormulaR1C1 = ComboBox1

End Sub

Private Sub CommandButton1_Click()

Sheets("Hoja2").Select

Selection.EntireRow.Insert

TextBox1 = Empty

ComboBox1 = Empty

TextBox1.SetFocus

End Sub

Private Sub TextBox1_Change()

Sheets("Hoja2").Select

Range("b2").Select

ActiveCell.FormulaR1C1 = TextBox1

End Sub

Featured Replies

publicado

Debes publicar el tema en el foro de macros.

En este dudo que alguien te conteste.

Además de no especificar el error, no has subido el archivo tal como indican las normas del foro.

Mira como hoy es domingo y estoy aburrido te daré unas pistas.

El error está provocado, casi seguro, porqué el valor de ComboBox1.ListIndex es igual a -1.

Una primera medida consiste en que en lugar de utilizar el evento Change utilices el evento Click, y de paso no estaría de mas que condicionaras código a que el valor de ComboBox1.ListIndex fuera distinto de -1.

O sea, debería quedar así:

[COLOR=#4D5153][B]Private Sub ComboBox1_Click()
[/B][/COLOR][COLOR=#4D5153][B]If [/B][/COLOR][B][COLOR=#4D5153]ComboBox1.ListIndex = -1 Then Exit Sub[/COLOR][/B][COLOR=#4D5153]
Hoja1.Select[/COLOR]
[COLOR=#4D5153]TextBox1.Value = Cells(ComboBox1.ListIndex + 1, 1).Offset(0, 1) [/COLOR]
[COLOR=#4D5153]Range("a2").Select[/COLOR]
[COLOR=#4D5153]ActiveCell.FormulaR1C1 = ComboBox1.[B]Text[/B][/COLOR]
[COLOR=#4D5153]End Sub[/COLOR][/CODE]

[color=#4D5153]

[/color]

Saludos.

Archivado

Este tema está ahora archivado y está cerrado a más respuestas.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.