Using VBA To Search And Retrieve Data From A Text File Containing A Code Library

Sometimes it’s easier to save information in a text file, rather than adding another sheet to a possibly already cluttered Excel application. In some instances, the use of a text file might be the only option in a particular situation.

This article will explain how you can organize a text file to make it easy to search for, and retrieve information.

Organizing The File

We’ll use the example of using a text file containing a code library, where you can store individual procedures for later use.

One way to search the file is to place your own tags around the code, so that your own VBA code can find the block of text and do something with it. In this case, the “tags” are already in place with the sub and end sub lines.

Perhaps your text file looks something like the text below and you want to retrieve the changeMe procedure which changes the color, bold and font type of the selected cell.

Sub firstCodeSnippet() 
' other subs 
end sub

Sub changeMe(cellAdress) Range(cellAddress).Select With Selection.Font .Name = “Tahoma” .Bold = True .ColorIndex = 3 End With End sub

Sub otherCodeSnippets() ‘ other subs end sub

Now, you just need to write some VBA code to retrieve the data.

First, you need to open the file using the file system object. Just replace your own file and folder names to the code below:

Our VBA code will read the file line by line, and only save data contained between the lines sub changeMe and end sub.

Next, we can set up a true or false trigger which will tell the code to start saving the data after it encounters the name of the procedure.

myProcedure = LCase("sub changeMe") 
startData = False 

Now, we read the data in the text file line by line.

Do Until myFile.AtEndOfStream 
txt = myFile.ReadLine 

When the code encounters sub changeMe in the text it begins to save the code to a string and adds a new line character until the line end sub. . Note the use of the lower case command to ignore capitals in the search.

If InStr(LCase(txt), myProcedure) > 0 Then startData = True 
If startData Then myCode = myCode & txt & vbCrLf 
If InStr(LCase(txt), "end sub") > 0 And startData = True Then Exit Do

‘ continue reading the file Loop

With the code saved, we can display the text in a message box with the following line:

Msgbox myCode 

Issues To Consider

Some practical issues to consider might be how to organize the search and display so the results are usable. Here are some ideas:

  • Use an input box to type in the code procedure you want to retrieve.
  • Print and laminate a sheet which lists all the entries in the library, so you can search for the appropriate code.
  • Instead of using a message box for the results, print the code to an immediate window or to a safe place in a worksheet.


Organizing code so it can be retrieved and used again is a challenging issue for most VBA developers. In just a few lines of code, this article has shown how you can save and search for code without the knowledge of more advanced concepts like user forms or plug-ins.

Investing In Farming As A Long-term Investment Decision To Be Able To Save For The Potential Future

Real estate property investments have always been a means for an investor to make money either speedily simply by selling and buying properties or perhaps over a lengthy time period by holding onto acreage until its price raises significantly and there is a purchaser willing to pay market price. One particular form of real estate, however, is now being viewed as an outstanding investment and thus a lot of best real estate investors happen to be starting to buy this type of real estate to hold.

Farmland will continue to be incredibly necessary long into the future, so it is usually considered a fantastic investment. Since the potential will there be for an individual to make a great deal on their investment, At this time, it might be simple to acquire farmland along with a small investment and get going owning properties that may be leased out now and used for farming. As time advances, it can be effortless to determine exactly how the farmland can be a fantastic investment. Provided that it’s cared for correctly, the farmland could continue to be utilized for years and also might be leased out to those that need to get started farming yet simply can’t afford to purchase the farmland by themselves.

Because of the nature of real-estate investments, it’s critical for somebody to be happy to keep their particular farmland for many years. A person can easily go to this web-site to be able to discover much more about exactly why this can be needed. The price of the land is likely going to go up and down throughout the time someone owns the property, so will the amount they’re able to get when they let the property to a farmer. Nonetheless, if perhaps the investment is actually kept for a long period of time, the person will stand the chance of make money from the rentals as well as through the sale of the real estate down the road.

In the event that you want to get started investing in properties, to understand a lot more regarding exactly why buying farmland is going to be regarded as an outstanding notion. In case you are prepared to invest, you can look here to be able to learn more concerning exactly what you ought to search for and also exactly how you can obtain farmland that may help you earn profits with time. Check it out right now

The Function and Form of Sub-Headlines in Copy

So far in my articles I’ve talked about headlines as distinct from the rest of the copy. Now I want to tell you about sub-headlines, because headlines really come in two parts, the headline itself and the sub-headline.

By the way, there may be other headings in the text. In a longer piece of copy there almost certainly will be. But these are not headlines. You may repeat some of the words you used in the headline, but the point you’re making will be different. These other headlines will be a kind of sub-headline. They may reinforce the headline directly, or expand it by adding other information.

Why do we use sub-headlines? So that the headline can be shorter and punchier is the first reason. Using other headings throughout the text also makes it more attractive and engaging. But brevity is not the most important reason we use a sub-headline near the top of our copy. The main reason we use sub-headlines is to qualify the claim we’ve made in the headline.

The point of the headline, as you’ll recall if you’ve read my previous articles, is to make a big claim that will grab the reader’s attention and prompt them to read on. The headline addresses the reader’s pain and promises, nay guarantees, to relieve it with a solution to their problem. What a sub-headline does is to explain, clarify, and define the big claim we made in the headline and maybe focus it more on the results, the timeframe, the lack of risk, and so on. A sub-headline often includes the word GUARANTEED. A sub-headline therefore makes our claim more credible and focused, and it also fulfills our ethical need to be accurate and honest in our copy about exactly what our product or service does.

Here’s another example from some of my copy.


” DISCOVER How YOU Can Explode Your Travel Recruitment Business & BOOST Your Income Sky-High In The Next THREE Months!”


“Harness the fantastic POWER of high-powered marketing materials to Win Clients, Build Relationships and Achieve a market-leading reputation as the No. 1 source of top-class enrichment staff for the cruise industry! ”
(Some of the words are in red, but that doesn’t matter.)

See how the sub-headline expands on the big claim I make in the headline and also makes the promise more specific and more attractive by spelling out three key results my copy can achieve. I should add that all promises made in copy assume that the copy is used in a professional, appropriate and ethical way. Copy doesn’t promise to make magic out of thin air. It does promise to achieve results which can seem magical when properly used. The fact that it does so has been proved on countless occasions.

When writing a sub-headline it’s natural, and best, to write it at the same time as you do the headline. Think of them as two hands doing the same job, rather than as pieces you add separately to your copy. Done well, your headline and sub-headline should make a compelling start to your copy.

The specialist in travel and health copywriting. The one-stop shop for all your business, study and personal written materials.

Understand Precisely How To Keep Track Of Stocks No Matter Where You Are

Those who want to enter into the stock market learn quickly exactly how crucial it can be to be able to constantly check their particular stocks. Even losing out on a good price by a few minutes could reduce the volume of profits they are able to make considerably. When the individual is actually interested in giving exchanging stocks a go, however they are unable to constantly observe the stock market by themselves, they could desire to  and check out a number of the ways making use of apps can help them.

There are actually quite a few apps that help individuals start selling and buying stocks. Anytime the individual looks at this weblink, they are able to get a much better notion of precisely what to expect with the apps. One of the main benefits associated with downloading an app is to make it simpler for them to purchase and sell stocks. When they will want to purchase or sell a stock, they are able to merely retrieve their particular phone or even tablet, make the right decision, as well as buy or sell the stock. This lets them purchase or sell stocks regardless of where they may be, even in the event they are on a bus or perhaps at the office on their lunch break.

Another advantage of the apps will be some of them will permit a person to set up status updates. If they’d like to know the instant a particular stock drops below a specific sum, they are able to set this up and be advised when it occurs. As they will recognize exactly when something takes place, they’ll be able to buy the stock quickly. They’re able to also be alerted if a stock goes up to a certain amount if they’d prefer to sell it at that time. Anytime they really are able to be informed of these types of changes, they are able to be certain they don’t overlook a wonderful deal that could assist them to earn money.

If perhaps you’d like to start exchanging stocks, you might wish to check over here as well as learn more with regards to exactly what apps are available and also precisely how they’re able to aid you. You can in addition learn so you are able to put far more belief in the info he’s providing you with and therefore feel a lot more at ease taking his advice. Go on and take a look at the details today in order to understand much more concerning what apps can be obtained and in order to locate one that’s going to assist you to get started buying and selling stocks even in case you cannot keep an eye on them all the time.

Read a Text File Using VB Dot Net

Read Text File using Classic VB

In classic VB reading a file is not that easy as we do in The first and easy way to access is using the simple file open method available in classic Visual Basic. Using this method, we can allocate a unique file number for opening the file. Further the same number has to be used for closing the file handle.

In addition to this, there are various modes a file can be opened. Some of them are Append, Binary, Input, Output, or Random. By default Random will be used.

Read text file in VB.Net

In we can read files very easily. The System.IO namespace contains really very useful set of functions which can reduce the effort and time in coding file related activities. One of the easiest is reading into string System.IO.File.ReadAllText(FilePath).

Using FileSystemObject in VB6 to Read a Text File

With FileSystemObject File IO operations are very easier in VB. Almost all the required functions are well defined. For reading, we have to use OpenTextFile method in the FileSystemObject. Once opened, A TextStream object can be used to fetch the data. To fetch line by line we need to loop through until we reach EOF. To find the EOF, FileSystemObject has a property AtEndOfStream. When it is true, it represents that the end of file is reached.

Using the Open method in VB6

Using a open method is much easier and effective way. It is well supported from a earlier versions of the visual basic. Because of it’s simplicity, we can see this in a lot of applications. Once it is opened please close it immediately after done working with the whole text fetched. This open method is working based on FileNumber. So the same FileNumber has to be used to close as well.

Search using Regular Expressions

If search string is not specified the function will give the entire content. If the search string is specified then the search results will be appended to a text and will be returned. The search is regular expression based search

Since the search is regular expression based, the regular expression should be validated before using the function. Or else the function will be hanging due to invalid regular expression.

The Need For Having A Monetary Counselor

Virtually anyone could use a little advice in relation to their own money. Expert experts can be found to be able to aid these wondering about their own budget and the way they could be enhanced. Nevertheless, a lot of people today feel that fiscal analysts are simply for the particular affluent. The truth is that virtually any group of people may utilize the experience associated with one of these expert folks.

On the subject of money, you’ll find a lot of unique types of agents available who can support. As an illustration, a specific professional could possibly be on the market to help somebody determine a mortgage or a housing bond. In such a case, this consultant probable makes a specialty of home loans and real estate investment. With that being said, you probably would not seek out a mortgage counselor while you are planning to invest in the particular stock trading game. People may read more below regarding shares and bonds.

If an individual is undoubtedly trying to create a number of key purchases, some might choose to think of speaking with a good investment counsellor. A great investment counsellor can assist a trader aiming to place their particular cash in the stock trading game. A specialist advisor can help a venture capitalist determine the type of shares they ought to select in an effort to fulfill their own economic targets. Potential buyers could have a glimpse with this  in order to find out about investing and the professionals available who is able to provide support.

The Ideal Habit for Young Adults to Develop

In the event that all the knowledge through almost all the wise men and women worldwide were to be compacted straight into one piece of advice and passed to each and every adolescent at the outset of his / her grown-up existence it becomes this: Work to become a saver. Only look at this site. Not many behaviour in life is going to bless you to the level at which this one can. Fight the need to amass personal debt at the moment when you see your closest friends buying autos, spending extravagantly, and taking on the type of debt that are going to require these people to work extended hours for several years to pay for them. Most really some day die still indebted – is this truly what you would like? It isn’t. Learn to exercise frugality very early and it shall surely pay off in the future.

For example, see thisIt includes recommendations for several things, much like getting the best interest levels along with home mortgages when purchasing a house. You might or will not be willing to get a property right now, nevertheless the morning may come while you are, and at this time it is going to really make a difference significantly to you. Exactly what the majority of young adults often fail to accomplish is always to look into the upcoming to take into consideration things which will one day really make a difference to these people. The time to start prepared to stay in that wise and elite lot of people that are provided the best charges and also loan products is now today..

It will take many years to build a a good credit rating, and having fine credit just might be the principal element in the particular method to finding the best in daily life. The finance bureaus have a tendency to examine stuff like persistence within a man or woman’s payment record, someone’s credit card debt to credit ratio, and also regardless of whether you have possessed a property foreclosure or even reported a bankruptcy proceeding. By being prepared to hold off pleasure in several things and also to exercise discretion along with intelligence upon others, you are able to eventually preserve thousands upon thousands of money. Examples include being willing to drive a pre-owned car, working in a second job, and also establishing the goal of financial independence from a young age. Visit this webpage here regarding more info

Cheap Flights to Athens

A glorious and magical worshipped by gods and humans alike, happens to be one of the most famous vacation destinations in Europe. With the sun shining over the city all year through, the climate is one of the best in that part of the world, making it an ideal place for tourism. There are several cheap flights to _3″> Athens plying on a regular basis, board one and embark on a vacation of a lifetime. This enchanting birthplace for civilization is laden with breathtaking views. If it’s not the magnificent landscapes that inspire you, the ancient and contemporary architecture will.

The city with distinct aspects is at once appealing and exciting. A walk around the famous historic triangle of Plaka, Thission and Psyri overwhelms you, a stroll in the old neighborhoods reveal the coexistence of different eras, and the mansions of yore, some well-preserved and some worn out by time present a striking contrast to the modern. The Greek capital dates back to mythological times and as a result the place is dotted with stamps of antiquity all through its surface. The city that you see in its entire splendor is a consequence of several influences, including ancient and medieval Greek, Roman, Byzantine and the contemporary era. Do a wise thing, come to the Greek capital equipped with a rather long stay, reason? The historical attractions are one too many. Start your journey with the South Slope of Acropolis, go on to the ancient Agora, visit the temple of Olympeion Zeus, spent a few hours admiring the Hadrian’s Arch and Library, go atop the Hill of Areopagus, the Hill of Philopappou and that of the Nymphs, and see Kerameikos. Attractions like Lysicrates’ Monument, Panathenaic Stadium, Roman Agora, Temple of Hephaestus, and the Tower of the Winds is also not to be missed.

Museums and art galleries showcasing creative arts are omnipresent throughout _4″> Athens with some giving a great insight into Greek archeology, history, modern art, while others dedicated to ceramics, music, railway etc. One of the unique selling points of _5″> Athens as a tourist destination is its close proximity to the whitewashed Greek islands. Enjoy one-day getaways, charming villages, ancient historical cities and equally fascinating and picturesque countrysides, each one with a varied color, culture and character. If you happen to be visit _6″> Athens with family, fret not. The city presents myriad options for all of you to enjoy together. These include parks and gardens, National Zoo, planetariums, educating and entertaining cultural centers, go-karting areas, and amusement parks. Places to stay and crash in are as varied as the attractions of the city itself. You can opt to stay at a luxurious five-star hotel, book yourself a bed and breakfast, stay in a holiday home or an apartment, or check into a cheap hotel accommodation. Culinary delights and gourmet foods can be relished and savored at any of the several world-class restaurants, or try a meal at the local eating joint, which is equally scrumptious and satisfying. For a prefect start to your holidays in Europe, come to first.

Now Available from Snapchat: Personalized Wedding Ceremony Filters Plus Much More

Snapchat is truly one of the more fulfilling cellular programs to come along recently, and it truly is wildly popular. Basically, Snapchat lets people who have this system downloaded on their particular mobile phones send out pictures/videos to people in their Snapchat pals list. There’s a catch, however: the photographs plus video clips vanish in mere seconds of being considered. In addition to currently being utilized to deliver these “At this point you view it, now you don’t” visible mail messages, they furthermore make it possible for people to mail texting as well as, customized photographs which have a cute caption, doodle or maybe overlay of some type on the top surface of them.

This very last feature may be a pleasurable strategy to let those who are present at an function, whether it’s a party, a proper function or maybe unplanned gathering, deliver an instant hello to people who were helpless to attend. Recently, Snapchat at last started providing Custom Snap Filters for a small fee. Individuals can even pattern their particular  when they so desire and distribute them for Snapchat’s approval so they have a unique overlay that pertains merely to their unique once ever function. Snapchat merely has existed a few brief years, yet by now it’s difficult for almost all young adults as well as grownups to visualize existence not having it.