Count frequency of words in a list - vba

I start by saying that I am not an expert user of VBA; I am just learning it.
I have a question regarding the possibility of counting text strings in Excel using a Macro. I cannot use the 'Countif' function, as there are more than 20,000 text strings in the Excel file, and it would be a lengthy procedure I guess.
I was therefore thinking about the possibility of using a VBA code to scan and organize text strings by their frequencies.
For instance, there are a set of words like this in my file (each in a different cell):
home,
balcony,
flat,
apartment,
home,
home,
garden,
thing,
revenue,
flat,
...
window
I would like to know if there's a way to make Excel scan all the different text strings and come back with the frequency for each of them.
I am aware that probably there are easier way to do it (e.g. Python or some add ins), but we have to do it at work, and I can't really ask my colleagues to learn Python or other programming languages, nor we have the capability to buy any software at the moment.
Thanks to those who can help!

Simple Pivot Table (without VBA - but could be code if needed)
See Debra's great website

Related

Change Info in Word from Excel VBA

I have a letter in Word that needs to be sent out to a number of contacts (example of letter). The only thing that needs to change in the letter is the recipients information
(example of how recipients info is stored), but I don't know what the best way to change this info is.
I did a little bit of research and what I've come across is that people either do a search and replace or use fields. I suspect that there is a better method than search and replace since I know exactly where the text needs to change. I'm thinking there might be something similar to named ranges like in excel?
Now this is where I came across fields, but to be honest I don't really understand them. I know they have a name but this whole equation thing throws me off. So my question is how do I change this information in the quickest/most efficient way?
I understand how to access and save word documents and am planning on using a loop to go through each row of contacts one by one, so if you have a solution you can leave that part out (unless you know of a better way!).

Advice for creating and scoring quizzes

I'm not sure where to actually post this (I'm pretty sure someone will chastize me tell me where after of course voting me down - expected).
I've been developing a bunch of files for Safety Training at my facility. The UI is built in Excel with Excel VBA at it's heart to get names and the Training program to run. The Excel file opens A PowerPoint presentation after getting your name and the program you desire and logs that data. When you are done with the presentation it opens as a Word doc - the quiz for that presentation.
My issue is this: currently all of our tests are created in Word (I barely know Word VBA) and would like to continue by just adding some text boxes and check boxes for the answers. I'd like to add some code to facilitate the automatic scoring of these tests by placing a button at the end that "locks" the test (so they can't change answers) then checks and returns the test score.
I don't see where Word Files can be locked as in Excel's "Protect Sheet". The scoring I am using seems to be flawed but that is an issue I can work out later if I stay with Word. I am wondering if it wouldn't be better and maybe easier to do this in Excel as it is set up more for evaluating data input.
Looking for any advice on what others might do if they had a choice to use Word or Excel for creating tests. I currently have no preference (except for the above - which I am not locked into) in which format to use, possibly even using a separate PowerPoint Presentation as the test itself.
To try to answer the question: What you are doing seems like a lot of fun from a VBA perspective, and from a user interface perspective, but it seems to me your intuition is telling you to move the test to excel and I think that is the right thing to do. You have much more ability to lock down the test, could easily score multiple tests and create a multi-test curve, etc, etc.

Looking to build a lineup builder for the site draftkings using excel

Why excel? Well excel is what is used to import the player salaries.
Now I need the spreadsheet to do the following.
Create teams within salary cap.
Include/exclude specific player function
Build multiple lineups from a selected list of players within the cap
Can I do all of this with excel? or do I need to know excel vba as well?
Also which parts of excel or if necessary excel vba must I need to know to code such a thing? Also if someone could give me a short summary of the steps needed to hypothetically make such a thing it would be great. Thanks.
I'm posting this as a reply because it is too long for a comment window.
Just because Excel has a grid doesn't mean that it is fit for data storage and data handling, on the contrary.
What you typically want to do is create a transparent structure that guarantees the integrity of your data and that allows dynamic portability when needed one day.
Excel is meant to be a spreadsheet, people forget this all the time or they just avoid the topic: although Excel has a grid, doesn't mean that it is a good fit for reliable data storage. It is not even the least complex way of storing data, depending on the amount of VBA that you need to manage all these data and the gates that you unnecessarily open towards potential bugs.
This is why an RDBMS is what will fit your needs, in this case Access would be a good option as it preserves your data integrity if you get the table structure right and it executes a lot of tasks for you that you should otherwise need to program yourself to protect the integrity of your data.
Although you can perform SQL on spreadsheets too, note that Excel does NOT cover related tables (what you typically seem to need for building your teams and salary limits), so what many Excel programmers will typically do is to create their own code to make this cross-table data storage thing work.
Don't do this if the alternative is available and much more reliable and future-proof.
At first sight, it seems that you won't even need any VBA; I'm not sure of all the things you want to do, but my first impression is that you can manage everything with SQL syntax and stored queries in MS Access. You can import Excel sheets into Access if you get their format right so that should not be a problem.
Once your data is stored there, rest assured that you have made your life a lot easier.

What would be an efficient way to see if a word exist when comparing to hundreds of thousands of words?

Iv'e been working with objective-c for while and I want to attempt to build an app. The app will be similar to a scrabble type of game. There are going to be drag and drop tiles (I already know how to program this) and a submit button. The only thing that I'm having trouble with is figuring out how I am going to compare the letters on the board to hundreds of thousands words without bogging down my program to much. What I have in mind, so far, is to store these the words in a database. Does objective-c have any kind of built in api that can access a standard dictionary database? I'm not referring to a dictionary array but rather an actual database with words and possibly definitions. Any thoughts on this?
I have used Lexicontext, it's $20, but it's worth it in my opinion, is extremely fast, there's a demo, and it contains a API for formatting definitions with CSS.
Looks like you're happy with the $20 solution. For the more adventuresome, the data structure you'd want to learn about is tries.
Imagine a tree with 26 children of the root, one for each letter in the alphabet. Now imagine that each child has 26 children, too. You can spell any word of length N by taking N steps from root to leaf. Now imagine that you prune the tree so it contains only valid words. That's your (very fast) word validator. It will take as long on average as your average word length.
Depending on how "Scrabble-like" your game actually is....
Are you going to be validating the word when the player presses submit?
That's not how Scrabble works. The player can play any (non)word so long as the opponents do not challenge the word.
So you'll need word validation in the "challenge" system, but it shouldn't happen as soon as the player plays the word. An unscrupulous player could then just place "maybe" words and press submit, to see if it actually is a valid word.

How to search an entire column for one or two keywords

I am in the process of creating a program, using Visual Basic Express, for a physics professor who has recently had to rename all 1500 questions for his course. I created a database that has the old names, new names, and the entire contents of each question. The program seemed an easy enough idea, but has proved to be very difficult for me. I am new to programming (this is only my third go at it) and have searched for an answer to my problem for at least 20 hours, and have yet to find anything that will work for what I need.
What I would like is to have a text box in which he can type in a keyword (such as "Sun", "ISS", "Force", etc) and for the program to search throughout the entire "questioncontents" column and pull out any questions that contain those words into the datagrid. As of yet the closest I have gotten is for it to search the first word of the column, which is not very useful since most of them start with "The".
I had also thought of creating several keyword columns and then just having it search through those, but I couldn't figure out how to apply the filter to multiple columns.
This may be a stupid question, and if so I apologize, but I am desperate to figure this out as the semester begins relatively soon and I would like to show him how to use it before classes start. Any suggestions or help would be very greatly appreciated.
According to my understanding of the question:
SELECT * FROM question WHERE questioncontent LIKE '%SUN%';
As simple as that, you just have to replace SUN in the above query with the value entered in the textbox