Saltar al contenido
PROGRAMAR EN VBA MACROS DE EXCEL

Como leer un archivo TXT separado coma con macro


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

En un ejemplo anterior se presentó una macro que lee archivos TXT, en el presente post muestro una macro que permite leer archivos TXT pero delimitados o separados por coma o punto y coma; es decir los datos que se encuentran en el archivo de texto plano, se encuentran separados por coma o punto y coma.

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.

  
El link que se encuentra al final de post permite descargar el ejemplo de macro denominada como leer un archivo TXT separado o delimitado por coma o punto y coma; consiste en un archivo comprimido conteniendo dos archivos uno de Excel con la macro y otro archivo TXT que se usa para mostrar el funcionamiento del ejemplo, pero se puede usar cualquier archivo que tenga cada lector en su PC cuyos datos se encuentren delimitados o separados por coma.

El ejemplo agrega en la variable cada una de las cadenas de texto, a través de la función de VBA Split; cuya separación entre datos este dada por punto y coma, en este caso, pero se puede ser coma, para ello se debe cambiar la siguiente parte del código:

texto = Split(cad, «;»)

por este código:

texto = Split(cad, «,»)

Luego se realiza un bucle hasta que se llegue al final de todas las lineas del archivo TXT; por cada una de las cadenas de texto separadas por punto y coma, que fueran cargadas en la variable texto a través de la función Split, las cuales se van agregando en las diferentes columnas de la hoja de Excel.

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 módulo
Sub opentxtseparadoscoma()
Application.ScreenUpdating = False
Application.DisplayAlerts = False
On Error Resume Next
Dim myfile As Variant, cad As String, fila As Long, texto() As String
Dim h As Long, fil As Long, col As Long
ruta = ActiveWorkbook.Path
ChDir ruta
myfile = Application.GetOpenFilename(«Archivos Txt (*.txt*), *.txt*»)
If VarType(myfile) = vbBoolean Then Exit Sub
Open myfile For Input As #1
fil = 1
col = 1
Cells.Clear
While Not EOF(1)
Line Input #1, cad
texto = Split(cad, «;»)
For h = 0 To UBound(texto)
Cells(fil, col) = fil
Cells(fil, col).Value = texto(h)
col = col + 1
Next h
col = 1
fil = fil + 1
Wend
Close #1
MsgBox («Los datos se leyeron con éxito»), vbInformation, «AVISO»
Application.ScreenUpdating = True
Application.DisplayAlerts = True
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 (96)

I’m the business owner of JustCBD label (justcbdstore.com) and I am currently seeking to develop my wholesale side of business. I really hope that someone at targetdomain give me some advice 🙂 I thought that the most suitable way to accomplish this would be to reach out to vape shops and cbd retail stores. I was hoping if someone could suggest a reliable web site where I can buy Vape Shop B2B Sales Leads I am presently looking at creativebeartech.com, theeliquidboutique.co.uk and wowitloveithaveit.com. Unsure which one would be the most suitable solution and would appreciate any assistance on this. Or would it be much simpler for me to scrape my own leads? Ideas?

Responder

I’m the owner of JustCBD brand (justcbdstore.com) and I’m presently planning to expand my wholesale side of business. I am hoping someone at targetdomain can help me ! I considered that the best way to accomplish this would be to reach out to vape shops and cbd stores. I was really hoping if anybody at all could suggest a dependable web site where I can purchase CBD Shops Business Data I am presently examining creativebeartech.com, theeliquidboutique.co.uk and wowitloveithaveit.com. Unsure which one would be the best solution and would appreciate any support on this. Or would it be easier for me to scrape my own leads? Suggestions?

Responder

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

Responder

I’m very happy to discover this web site. I wanted to thank you for your time due to this fantastic read!! I definitely loved every bit of it and i also have you saved to fav to check out new information in your site.

Responder

I needed to thank you for this fantastic read!! I certainly enjoyed every little bit of it. I’ve got you saved as a favorite to check out new things you post…

Responder

Spot on with this write-up, I honestly think this web site needs a great deal more attention. I’ll probably be back again to see more, thanks for the advice!

Responder

I’m very pleased to discover this website. I need to to thank you for ones time due to this fantastic read!! I definitely loved every little bit of it and I have you book-marked to look at new stuff in your site.

Responder

I used to be able to find good information from your blog posts.

Responder

I simply want to mention I’m new to blogging and actually loved you’re web site. Very likely I’m going to bookmark your site . You amazingly have really good well written articles. Thank you for revealing your web page.

Responder

Very descriptive post, I enjoyed that a lot. Will there be
a part 2?

Responder

If you wish for to get a good deal from this piece of writing then you have
to apply such strategies to your won web site. adreamoftrains website hosting

Responder

I simply want to mention I’m all new to blogging and site-building and honestly enjoyed your page. Likely I’m going to bookmark your blog post . You absolutely have excellent articles and reviews. With thanks for sharing with us your webpage.

Responder

Good reading, but I need to read 1 more time. Thanks! Will be good for this month SEO Service project.

Responder

Hi! I simply would love to give a huge thumbs up for the excellent information you have below on this blog post. I will be returning to your blog site for even more soon.

Responder

Acquire our Keto quiz in order to configure your own personalised Keto meal plan. Consider the KETO quiz… Acquire everything you need to achieve success with the Keto diet.

Responder

pitkävetovihjeet

Responder

KAISERSLUST Plattform der Wiener Sex Scene Sex in Wien – Girls in Wien – Escorte Wien – Transen Wien – Hostessen Wien Escort Wien – Massagen Wien – Studios Wien – Laufhaus und Bordelle Wien Asiatinnen Wien – Sex in Wien – Kaiserslust – Der Kaiser hat Lust – Sex

Responder

Leptitox can be a feasible weight-loss dietary supplement by Morgan Hurst and Sonya Rhodes. What differentiates it from the remainder of its sort is its all-normal composition. This implies the system will not leverage artificial components or artificial compounds to provide effects. This type of chemical-dependent Alternative generally reaps Uncomfortable side effects – a downside You cannot overlook.

Responder

Wonderful article! This is the kind of information that are
meant to be shared across the net. Disgrace on Google for
no longer positioning this post higher! Come on over and
visit my website . Thank you =) cheap flights 3gqLYTc

Responder

Shop; Unique Functions. Simple Product Layouts. Post with review. Advanced Product Layout. Best conversion pages. Frontend Search · Listing example …

Responder

Why visitors still make use of to read news papers when in this technological world all is existing on net?
cheap flights yynxznuh

Responder

netticasinot pikakasinot parhaat netticasinot

Responder

Welcome to iBeautys Best, iBeautys Best is the number one destination for Latest Beauty Products. Here you can easily buy your desired product from all over the world with very reasonable price.

Responder

David-Home Northeast is your premier source for all of your Real Estate investing needs. We provide a variety of solutions for sellers looking to sell fast and investors looking to grow their real estate investment portfolios for better returns. At David-Home Northeast, we are dedicated to improving and redeveloping the areas that we operate in. We specialize in helping sellers of distressed properties (single and multi-family homes, commercial, retail, bank REOs, etc.) find buyers looking to invest. Let us put our network of cash home buyers and private money lenders to work for you so you can say “David” to that old unwanted property.

Responder

I’m extremely inspired along with your writing skills and also
with the structure for your weblog. Is this a paid theme or did you customize it yourself?
Anyway stay up the nice high quality writing, it is uncommon to see a great weblog like this one today..

Responder

Thank you for sharing your info. I really appreciate your efforts and I am waiting for your further
write ups thanks once again.

Responder

David-Home Northeast is your premier source for all of your Real Estate investing needs. We provide a variety of solutions for sellers looking to sell fast and investors looking to grow their real estate investment portfolios for better returns. At David-Home Northeast, we are dedicated to improving and redeveloping the areas that we operate in. We specialize in helping sellers of distressed properties (single and multi-family homes, commercial, retail, bank REOs, etc.) find buyers looking to invest. Let us put our network of cash home buyers and private money lenders to work for you so you can say “David” to that old unwanted property.

Responder

really great post, i absolutely love this internet site, keep on it

Responder

Hello everyone, it’s my first go to see at this website, and piece of writing is really fruitful in support of me, keep up posting these posts.

Responder

Natural Releaf CBD | New York CBD Store with locations in Murray Hill, NY | Upper East Side, NY | White Plains, NY Serving New York City, NY and Westchester, NY High Quality CBD Products With Lab Test

Responder

Is Ibogaine effective in treating opiate withdrawal

Responder

Love watching sunset !

Responder

Love watching sunset !

Responder

Nice response in return of this matter with real arguments and telling all regarding that.

Responder

There are some intriguing points in time in this post however I don?t understand if I see all of them facility to heart. There is some credibility however I will take hold point of view until I check out it better. Excellent post, thanks as well as we desire much more! Added to FeedBurner too

Responder

Best view i have ever seen !

Responder

Löydä aito seksi chatti kaveri jo tänään! Rekisteröidy ilmaiseksi ja aloita keskustelut jo tänään! Seksi chat ei jätä ketään kylmäksi edes tammikuussa!

Responder

xxx pornoa, xxx porn, free xxx porn, tube free, xxx pornoa

Responder

It is extremely awesome ! Thank you for this topic. I will read the next one

Responder

Love watching sunset !

Responder

Love watching sunset !

Responder

Best view i have ever seen !

Responder

ilmaiset videot, ilmaiset pornovideot, ilmaiset porno videot, porno video, porno videot

Responder

Wow! This can be one particular of the most helpful blogs We have ever arrive across on this subject. Actually Wonderful. I am also a specialist in this topic so I can understand your hard work.

Responder

Hey there! I just would like to give a significant thumbs up for the wonderful details you have here on this article. I will certainly be coming back to your blog site for more quickly.

Responder

cbd oil

Responder

We are building consultants. We perform roof assessments, window testing, and wall testing for quality assurance on new and existing buildings.

Responder

It?s hard to discover educated people on this subject, but you seem like you recognize what you?re speaking about! Many thanks

Responder

Online jewelry boutique specializing in custom gold and silver pieces. For the hippy hearted fashion lover. Known for its custom lotus flower hoop earrings and large collection of hoop earrings. Customers enjoy the classic and unique versatile everyday jewelry designs. Glamour hippy began is also known for its dainty gold jewelry pieces. Bohemian chic styles with modern fashion flare. Great prices and affordable. Everyday pieces to statement piece designs for special occasions. Glamour hippy is inspired by diverse world culture and it reflects into the ever changing designs. Its customer enjoys unique pieces and comfort in style. Glamour hippy wants to be a part of its customers wardrobe for many years and part of great memories where ever the customer takes their jewelry pieces. Glamour hippy is glamour and hippy all in one. Shiny pretty pieces, Unique, Glamorous, boho chic, one of a kind, dainty, but statement worthy.

Responder

netticasinot, netticasino, casino, kasinot, nettkasinot

Responder

Aw, this was a truly wonderful message. In suggestion I wish to put in writing similar to this in addition? taking time as well as real initiative to make a great write-up? however what can I say? I procrastinate alot and by no means seem to obtain something done.

Responder

GEM-CAR auto repair shop management software is arguably the most comprehensive software of its kind currently available. Lauded for its easy to use modules including CRM, digital inspection and electronic punch clock: it provides the repair shop operator with a complete system to run the business. GEM-CAR puts the shop operator firmly in the driver’s seat. And if you are a fleet operator look for GEM-FLEET our fleet management software.

Responder

netticasinot, parhaat netticasinot, netticasino

Responder

I really appreciate this post. I have been looking everywhere for this! Thank goodness I found it on Bing. You’ve made my day! Thanks again

Responder

I’ve been browsing online more than 3 hours today, yet I never found any interesting article like yours. It’s pretty worth enough for me. In my view, if all webmasters and bloggers made good content as you did, the internet will be a lot more useful than ever before.

Responder

Many thanks to you for sharing these types of wonderful blogposts. In addition, an excellent travel as well as medical insurance approach can often ease those concerns that come with journeying abroad. The medical crisis can before long become expensive and that’s sure to quickly set a financial stress on the family’s finances. Having in place the suitable travel insurance program prior to leaving is worth the time and effort. Thank you

Responder

Good blog post. I discover something a lot more difficult on various blogs daily. It will certainly always be promoting to review material from other writers and also exercise a something from their store. I?d prefer to utilize some with the web content on my blog whether you don?t mind. Natually I?ll provide you a web link on your web blog. Many thanks for sharing.

Responder

Thanks a lot for sharing this with all folks you actually know what you are talking about! Bookmarked. Please additionally consult with my website =). We may have a hyperlink exchange agreement among us!

Responder

SHOP ALL BIKE mission is to provide only the finest & high quality Bike Accessories. Products available, backed by fast, efficient and accurate service. SHOP ALL BIKE is committed to doing all of this, and still maintain very competitive pricing

Responder

Helpful info. Fortunate me I discovered your web site unintentionally, and I’m stunned why this twist of fate didn’t came about in advance! I bookmarked it.

Responder

pikakasinot, kasinot ilman rekisteröitymistä

Responder

pikakasinot, kasinot ilman rekisteröitymistä

Responder

buy illegal drugs online

Responder

Aw, this was an actually good article. In idea I would love to put in composing like this furthermore? taking some time and also actual effort to make a great article? yet what can I say? I procrastinate alot and never seem to obtain something done.

Responder

You actually explained it superbly. cbd oil for pain

Responder

bonukset

Responder

A person necessarily assist to make significantly posts I might state. That is the very first time I frequented your web page and up to now? I surprised with the analysis you made to make this particular publish extraordinary. Wonderful activity!

Responder

I like this post, enjoyed this one thanks for posting. «To the dull mind all nature is leaden. To the illumined mind the whole world sparkles with light.» by Ralph Waldo Emerson.

Responder

iphone cheap rate

Responder

Find The Top Rated Web Hosting

Responder

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

Responder

}

Responder

Woah! I’m really enjoying the template/theme of this website. It’s simple, yet effective. A lot of times it’s very difficult to get that «perfect balance» between user friendliness and visual appearance. I must say that you’ve done a great job with this. In addition, the blog loads very fast for me on Safari. Excellent Blog!

Responder

casual hookup

Responder

My brother recommended I would possibly like this web site. He was entirely right. This submit actually made my day. You cann’t imagine just how much time I had spent for this info! Thanks!

Responder

When I initially commented I clicked the -Alert me when new remarks are included- checkbox and now each time a comment is added I obtain 4 emails with the same comment. Exists any way you can remove me from that service? Many thanks!

Responder

buy drugs online legally

Responder

I want to show my gratitude for your kind-heartedness giving support to persons who have the need for assistance with your concept. Your very own dedication to passing the solution all through appeared to be wonderfully practical and has without exception helped those much like me to reach their desired goals. The helpful tips and hints implies much to me and additionally to my peers. Best wishes; from each one of us.

Responder

I?d have to contact you here. Which is not something I typically do! I take pleasure in checking out a blog post that will certainly make individuals think. Also, many thanks for allowing me to comment!

Responder

What i do not understood is actually how you’re not actually much more well-liked than you might be right now. You’re so intelligent. You realize therefore significantly relating to this subject, made me personally consider it from a lot of varied angles. Its like men and women aren’t fascinated unless its one thing to accomplish with Lady gaga! Your own stuffs outstanding. Always maintain it up!

Responder

Our Mushroomburger The signature Mushroomburger patty was created back in 1979. Still to everyone’s surprise, it is approximately made up of 50 mushrooms and 50 real beef.

Responder

Pretty! This has been an extremely wonderful post. Thanks for supplying this information.

Responder

What i do not realize is in truth how you’re no longer really much more well-appreciated than you might be right now. You are very intelligent. You recognize thus considerably when it comes to this subject, produced me personally consider it from a lot of various angles. Its like men and women are not interested except it is something to do with Girl gaga! Your personal stuffs outstanding. At all times care for it up!

Responder

Thank you for all your valuable work on this web site. My mom take interest in conducting internet research and it’s really easy to understand why. A number of us learn all relating to the compelling way you make functional guidance via your web blog and recommend response from some other people on the concern plus our favorite simple princess is without a doubt becoming educated a lot. Take advantage of the rest of the year. You are always doing a wonderful job.

Responder

book hotels, find hotels, discount hotels, hotel deals, compare hotels, search for hotels, best hotels, hotel deals, hotel packages, city packages

Responder

An impressive share! I have just forwarded this onto a friend who had been conducting a little research on this. And he actually bought me dinner simply because I stumbled upon it for him… lol. So allow me to reword this…. Thanks for the meal!! But yeah, thanks for spending the time to talk about this subject here on your blog.

Responder

netticasinot, parhaat netticasinot, netticasino

Responder

Wonderful website. A lot of useful information here. I am sending it to some friends ans also sharing in delicious. And certainly, thanks for your sweat!

Responder

My spouse and I absolutely love your blog and find almost all of your post’s to be precisely what I’m looking for. Does one offer guest writers to write content to suit your needs? I wouldn’t mind publishing a post or elaborating on a few of the subjects you write concerning here. Again, awesome web site!

Responder

There is noticeably a package to find out about this. I think you made sure nice factors in attributes additionally.

Responder

Site Rank Services offers affordable premium SEO packages & helps increase the visibility of your site in the search engines. We help you generate more profits

Responder

You made some first rate points there. I appeared on the internet for the difficulty and located most people will go together with together with your website.

Responder

Shopify fitness store

Responder

I was just seeking this info for a while. After 6 hours of continuous Googleing, at last I got it in your site. I wonder what’s the lack of Google strategy that don’t rank this type of informative websites in top of the list. Usually the top websites are full of garbage.

Responder

Just desire to say your article is as astounding. The clarity in your post is simply spectacular and i could assume you are an expert on this subject. Fine with your permission allow me to grab your RSS feed to keep updated with forthcoming post. Thanks a million and please carry on the enjoyable work.

Responder