Saltar al contenido
PROGRAMAR EN VBA MACROS DE EXCEL

Llenar combobox y copiar datos en celda de hoja de Excel


(adsbygoogle = window.adsbygoogle || []).push({});

En combobox incrustado en hoja de Excel se muestra como incrustar un combobox  en la hoja de Excel y seleccionar ítems desde el mismo, en este ejemplo la Macro realizada en VBA ejecuta un procedimiento sencillo, pero útil para comprender como copiar los datos del combo box a una celda de la hoja de Excel.

Al descargar el archivo, se podrá observar dos hojas, haciendo click en la imagen se  podrá ver su aspecto; una llamada Factura y otra llamada Clientes, la primer hoja tiene un espacio para cargar datos de productos, es una forma muy simplificada de una factura, en su parte superior se encuentra un botón el cual llama a un formulario, este formulario consta de un combobox y dos CommandButton o botones de comando, con un botón se cierra el formulario y con el otro se acepta el dato seleccionado en el combobox, el cual se copia automáticamente en la celda destinada a ingresar el nombre del cliente, luego de ello el formulario se oculta, en caso que se acepte y el combobox esté vacío, sale un msgbox indicando que se debe cargar un dato previamente.

En este Blog hay varios post relacionados  con la búsqueda de datos a través de Macros de Excel o Procedimientos de VBA en el post buscar datos en tres columnas; si  quieres más ejemplos sobre como buscar datos deberías ver  como buscar datos en todas las filas  en base  a criterios. Si visitas el mapsite de este sitio,  podrás buscar en el índice del blog y descargar el ejemplo que necesites. 

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.
  

En el post anterior combobox incrustado en hoja de Excel se explicaba en detalle como incrustar un combobox  en la hoja de Excel y seleccionar ítems desde el mismo, en este otro ejemplo la Macro realizada en VBA ejecuta un procedimiento muy similar, con la variante que en vez de estar incrustado en la hoja de Excel, el combobox está en un formulario, a lo que se agrega que se puede seleccionar el archivo donde buscar. Si bien hacen diferentes procedimientos en ambos se trabaja con combo box, lo cual sugiero que veas para comprender en forma más acabada  su uso.

El vídeo que sigue muestra una explicación más detallada y gráfica de la macro presentada, recomiendo observar para una más fácil comprensión de la macro; suscribe a nuestra web desde la parte superior derecha de la página ingresando tu mail y a nuestro canal de You Tube para recibir en tu correo vídeos explicativos sobre macros interesantes, como  por ejemplo Las 1000 mejores macros de Excelbuscar en listbox mientras escribes en textbox, como copiar tablas vinculadas de Excel a Wordconectar Excel con Access y muchos ejemplos más.

Código que se inserta en un formulario, haz click para descargar el archivo de ejemplo

 

Private Sub CommandButton1_Click()
If ComboBox1 = Empty Then
MsgBox («Se requiere que seleccione un nombre»), vbCritical, «AVISO»
ComboBox1.SetFocus
Exit Sub
End If
Sheets(«Factura»).Cells(2, 2) = ComboBox1
Unload Me
Sheets(«Factura»).Select
End Sub

Private Sub CommandButton2_Click()
Unload Me
End Sub

Private Sub UserForm_Initialize()
Application.ScreenUpdating = False
ComboBox1.Clear
Sheets(«Clientes»).Select
Range(«A2»).Select
While ActiveCell <> Empty
ComboBox1.AddItem ActiveCell
ActiveCell.Offset(1, 0).Select
Wend
End Sub

Código que se inserta en un módulo

Sub muestraform()
UserForm1.Show
End Sub


Si te fue de utilidad puedes INVITARME UN CAFÉ y de esta manera ayudar a seguir manteniendo la página, CLICK para descargar en ejemplo en forma gratuita.

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      

Entradas relacionadas

Deja una respuesta

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *

Comentarios (33)

I think that what you posted was actually very
logical. However, think on this, what if you
added a little information? I ain’t saying your information isn’t solid, but what if you added a post title that makes people want more?
I mean Llenar combobox y copiar datos en celda de hoja de Excel
– PROGRAMAR EN VBA MACROS DE EXCEL is kinda vanilla.
You should peek at Yahoo’s front page and watch how
they write post headlines to get people interested.

You might try adding a video or a picture or two to grab people
interested about everything’ve written. In my opinion, it
would make your blog a little livelier.

Responder

My brother suggested I might like this blog.
He was entirely right. This post actually made my
day. You cann’t imagine simply how much time I had
spent for this information! Thanks!

Responder

Excellent blog here! Also your web site loads up fast! What web host are you
using? Can I get your affiliate link to your host?
I wish my site loaded up as fast as yours
lol

Responder

Very nice post. I just stumbled upon your weblog and wanted to say that I have truly enjoyed surfing around your blog
posts. After all I will be subscribing to your rss feed and I hope
you write again soon!

Responder

I feel that is among the so much important info for me.
And i’m glad studying your article. But wanna remark on few normal things,
The site taste is ideal, the articles is truly excellent :
D. Good task, cheers

Responder

What’s up i am kavin, its my first time to commenting anywhere, when i read this article i thought i could also create
comment due to this sensible post.

Responder

If you want to improve your knowledge just keep visiting this
site and be updated with the most up-to-date gossip posted here.

Responder

What’s up, its good paragraph about media print, we all know media is a
wonderful source of facts.

Responder

Pretty! This was an extremely wonderful article. Thanks for supplying this information.

Responder

Aw, this was an exceptionally good post. Taking a few minutes and actual effort to produce
a very good article… but what can I say…
I hesitate a whole lot and never manage to get nearly anything done.

Responder

A motivating discussion is definitely worth comment.
I do believe that you should publish more about this subject matter, it might not be a
taboo matter but usually people don’t discuss such topics.
To the next! All the best!!

Responder

We absolutely love your blog and find almost all of
your post’s to be exactly what I’m looking for.
can you offer guest writers to write content in your case?
I wouldn’t mind producing a post or elaborating on a few of the subjects you write with regards to
here. Again, awesome blog!

Responder

My brother recommended I would possibly like
this website. He was once entirely right. This put up actually made my day.
You cann’t consider just how a lot time I had spent for
this information! Thank you!

Responder

Hello, just wanted to say, I liked this post. It was funny.
Keep on posting!

Responder

Really when someone doesn’t know then its up to other users that they will assist, so here it takes place.

Responder

I know this if off topic but I’m looking into starting my own blog and was wondering what all is required to get
set up? I’m assuming having a blog like yours
would cost a pretty penny? I’m not very internet smart so I’m not 100% certain. Any suggestions or advice would be greatly appreciated.
Thank you

Responder

My spouse and I absolutely love your blog and find many
of your post’s to be exactly I’m looking for.
Do you offer guest writers to write content available for you?
I wouldn’t mind composing a post or elaborating on most of the subjects you write in relation to here.
Again, awesome web site!

Responder

Thank you for sharing your info. I really appreciate your efforts and I will be waiting for your next
write ups thank you once again.

Responder

Hi mates, how is everything, and what you desire to say on the topic of this piece of writing, in my view its really amazing designed for
me.

Responder

My brother recommended I might like this blog. He
used to be entirely right. This post actually made my day.
You can not consider just how much time I had spent for
this information! Thank you!

Responder

A person necessarily lend a hand to make critically articles I might state.
This is the very first time I frequented your website page and to this point?
I surprised with the research you made to create
this actual publish amazing. Wonderful activity!

Responder

Thanks for the good writeup. It in truth was once a leisure account it.
Look advanced to more added agreeable from you! By the way, how could we keep
up a correspondence?

Responder

I absolutely love your blog.. Excellent colors & theme.
Did you build this amazing site yourself?

Please reply back as I’m attempting to create my own blog and want to find out where you
got this from or what the theme is called. Thanks!

Responder

Touche. Solid arguments. Keep up the amazing spirit.

Responder

I just like the helpful info you supply to your articles.
I’ll bookmark your blog and take a look at once more right here regularly.
I am moderately sure I will be told many new
stuff right here! Best of luck for the next!

Responder

Hello! I could have sworn I’ve visited this web site before but after going
through many of the posts I realized it’s new to me.
Regardless, I’m certainly pleased I came across it and I’ll be bookmarking it and checking back often!

Responder

Someone essentially assist to make seriously posts I might state.
That is the very first time I frequented your web
page and thus far? I amazed with the analysis you made
to create this particular publish extraordinary. Wonderful job!

Responder

Have you ever thought about publishing an ebook or guest authoring on other blogs?

I have a blog centered on the same information you discuss and would really like to have you share
some stories/information. I know my viewers would enjoy your work.
If you’re even remotely interested, feel free to shoot me an e mail.

Responder

Hello i am kavin, its my first time to commenting anywhere,
when i read this piece of writing i thought i could
also make comment due to this sensible post.

Responder

Have you ever considered creating an e-book
or guest authoring on other sites? I have a blog based upon on the same subjects you discuss and
would love to have you share some stories/information. I know my subscribers would enjoy your work.

If you are even remotely interested, feel free to shoot me an email.

Responder

Everything is very open with a really clear description of the issues.

It was really informative. Your website is very helpful.
Thanks for sharing!

Responder

I’m not positive the place you’re getting your info, however good topic.

I needs to spend some time studying much more or understanding more.
Thank you for wonderful info I was in search of this info for my mission.

Responder

I like the helpful information you provide in your articles.

I’ll bookmark your blog and check again here regularly.
I’m quite sure I will learn many new stuff right here!
Best of luck for the next!

Responder