Saltar al contenido
PROGRAMAR EN VBA MACROS DE EXCEL

Macro para Insertar Columnas


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

En este post voy a mostrar distintas maneras de insertar columnas mediante macros con VBA, es decir aprenderás a como crear una macro para insertar columnas en Excel, si bien es bastante sencillo es útil manejar las distintas formas de hacerlo.

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.

  

Con el código que se muestra a continuación   se está diciendo que inserte una columna delante de la columna A
Range(«B:B»).Columns.Insert
También se puede usar el código siguiente obteniendo el mismo resultado.
Range(«B2»).EntireColumn.Insert
Para insertar varias columnas a la vez se debe seleccionar o referenciar el rango donde se desea insertar las columnas, en este caso se insertan dos columnas ya que se seleccionaron las columnas B y C.

Range(«B:C»).Columns.Insert

Con el código siguiente lo que se hace es cortar las columnas B y C, seleccionado la Columna G e insertando las columnas cortadas
Range(«B:C»).Cut
Columns(«G:G»).Select
Selection.Insert Shift:=xlToRight
El código anterior se puede simplificar un poco obviando la selección quedando así:
Range(«B:C»).Cut
Columns(«G:G»). Insert Shift:=xlToRight

Al final hay un link del cual podrás descargar el ejemplo y adaptarlo a tus necesidades, el código se encuentra abierto y sin ningún tipo de restricción, te recomiendo descargar el ejemplo y ver su codificación y funcionamiento.

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 formulario que crea un listado de todas las hojas para poder luego seleccionarlasbuscar en listbox mientras escribes en textboxordenar hojas libro excel por su nombreconectar Excel con Access y muchos ejemplos más.

function onYtEvent(payload) {
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 userform

Sub InserCol1()
Range(«B:B»).Columns.Insert
End Sub

Sub InserCol2()
Range(«B2»).EntireColumn.Insert
End Sub

Sub InserColran()
Range(«B:C»).Columns.Insert
End Sub

Sub InsColcorder()
Range(«B:C»).Cut
Columns(«G:G»).Select
Selection.Insert Shift:=xlToRight
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.


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

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 un comentario

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

Comentarios (32)

I’m the business owner of JustCBD Store company (justcbdstore.com) and am looking to grow my wholesale side of company. I am hoping anybody at targetdomain give me some advice ! I considered that the very best way to accomplish this would be to reach out to vape companies and cbd retailers. I was hoping if anybody could recommend a reliable web site where I can buy CBD Shops B2B Marketing List I am currently reviewing creativebeartech.com, theeliquidboutique.co.uk and wowitloveithaveit.com. Not sure which one would be the best solution and would appreciate any guidance on this. Or would it be simpler for me to scrape my own leads? Ideas?

Responder

неспособность организации полностью удовлетворить требования кредиторов субсидиарная ответственность тема знакома каждому владелецу бизнеса

Responder

I was very happy to discover this web site. I want to to thank you for your time due to this fantastic read!! I definitely savored every little bit of it and i also have you book-marked to check out new information in your site.

Responder

Everything is very open with a very clear explanation of the issues. It was truly informative. Your site is extremely helpful. Many thanks for sharing!

Responder

The next time I read a blog, Hopefully it won’t disappoint me as much as this particular one. I mean, Yes, it was my choice to read through, nonetheless I really thought you would probably have something helpful to say. All I hear is a bunch of moaning about something that you could fix if you were not too busy seeking attention.

Responder

Hi, I do think this is an excellent web site. I stumbledupon it 😉 I am going to come back once again since i have book marked it. Money and freedom is the best way to change, may you be rich and continue to help others.

Responder

I absolutely love your website.. Excellent colors & theme. Did you make this amazing site yourself? Please reply back as I’m attempting to create my own site and would like to know where you got this from or what the theme is called. Many thanks!

Responder

Can I simply say what a relief to find a person that actually knows what they’re talking about on the internet. You certainly realize how to bring a problem to light and make it important. More and more people have to check this out and understand this side of the story. I was surprised that you are not more popular since you surely possess the gift.

Responder

Hello there! This blog post couldn’t be written any better! Going through this article reminds me of my previous roommate! He constantly kept talking about this. I’ll send this article to him. Fairly certain he’s going to have a great read. I appreciate you for sharing!

Responder

Everything is very open with a very clear clarification of the issues. It was truly informative. Your website is very helpful. Many thanks for sharing!

Responder

After going over a number of the blog articles on your web site, I truly appreciate your way of writing a blog. I saved as a favorite it to my bookmark webpage list and will be checking back soon. Take a look at my web site too and let me know your opinion.

Responder

I truly love your website.. Very nice colors & theme. Did you develop this website yourself? Please reply back as I’m looking to create my own website and would love to learn where you got this from or just what the theme is called. Cheers!

Responder

An outstanding share! I have just forwarded this onto a co-worker who has been doing a little research on this. And he in fact ordered me breakfast simply because I found it for him… lol. So allow me to reword this…. Thanks for the meal!! But yeah, thanx for spending the time to talk about this issue here on your web site.

Responder

The very next time I read a blog, Hopefully it doesn’t fail me just as much as this particular one. I mean, I know it was my choice to read through, nonetheless I truly thought you would probably have something useful to talk about. All I hear is a bunch of moaning about something that you could fix if you weren’t too busy looking for attention.

Responder

Hi, I do believe this is an excellent website. I stumbledupon it 😉 I will revisit once again since I saved as a favorite it. Money and freedom is the best way to change, may you be rich and continue to help other people.

Responder

This is the right blog for anybody who really wants to find out about this topic. You realize so much its almost hard to argue with you (not that I actually will need to…HaHa). You definitely put a new spin on a subject that has been written about for decades. Wonderful stuff, just wonderful!

Responder

Your style is unique compared to other people I’ve read stuff from. Thanks for posting when you have the opportunity, Guess I’ll just bookmark this blog.

Responder

There’s definately a great deal to know about this issue. I love all the points you’ve made.

Responder

May I just say what a comfort to find somebody who actually understands what they’re discussing on the internet. You certainly realize how to bring a problem to light and make it important. A lot more people really need to read this and understand this side of the story. I was surprised you aren’t more popular given that you surely possess the gift.

Responder

Way cool! Some very valid points! I appreciate you penning this write-up and the rest of the site is also really good.

Responder

Excellent blog you’ve got here.. It’s difficult to find good quality writing like yours nowadays. I honestly appreciate people like you! Take care!!

Responder

I’m amazed, I have to admit. Rarely do I come across a blog that’s both educative and entertaining, and without a doubt, you’ve hit the nail on the head. The problem is something which too few people are speaking intelligently about. Now i’m very happy I found this during my search for something regarding this.

Responder

An outstanding share! I have just forwarded this onto a friend who had been conducting a little homework on this. And he actually ordered me lunch due to the fact that I discovered it for him… lol. So allow me to reword this…. Thanks for the meal!! But yeah, thanx for spending time to talk about this issue here on your web site.

Responder

The next time I read a blog, Hopefully it doesn’t fail me as much as this particular one. I mean, Yes, it was my choice to read through, nonetheless I really thought you would have something interesting to say. All I hear is a bunch of crying about something you can fix if you were not too busy searching for attention.

Responder

Hi! I could have sworn I’ve been to this web site before but after browsing through many of the posts I realized it’s new to me. Nonetheless, I’m certainly delighted I came across it and I’ll be bookmarking it and checking back regularly!

Responder

Your style is very unique compared to other folks I’ve read stuff from. Many thanks for posting when you’ve got the opportunity, Guess I will just book mark this site.

Responder

Everything is very open with a precise explanation of the issues. It was definitely informative. Your site is extremely helpful. Thank you for sharing!

Responder

Good article. I will be dealing with a few of these issues as well..

Responder

I really like reading an article that can make men and women think. Also, thanks for allowing for me to comment!

Responder

Hello there! Would you mind if I share your blog with my facebook group?
There’s a lot of folks that I think would really enjoy your content.
Please let me know. Cheers

Responder

I know this if off topic but I’m looking into starting my own blog and
was curious 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 web smart so I’m not 100% certain. Any tips or advice
would be greatly appreciated. Thank you adreamoftrains website hosting services

Responder

Spot on with this write-up, I actually think this site needs far more attention. I’ll probably be returning to read through more, thanks for the advice!

Responder