Quizzes & Puzzles2 mins ago
Using Vba To Automatically Assign Gender In Excel Spreadsheet
4 Answers
A couple of days ago, I posted about automatically filling in empty cells underneath a gender column based on the first name in the same row. I have found moderate success by downloading an MS Access database (http://www.codeproject.com/Articles/2169/Name-genderization) with 6000 names and corresponding genders preloaded, copying this database into an adjacent excel sheet and using the VLOOKUP function. However, it doesn’t seem to list a lot of foreign names, namely Middle Eastern and Chinese. So I found a fairly reliable and simple baby name guesser website (http://www.gpeters.com/names/baby-names.php) to supplement this list. My idea would be, when the VLOOKUP turns up a “#N/A” for the gender of the member’s name (since I have the VLOOKUP set to “False”), to have a code (preferably in VBA) run that submits the name to the baby name guesser website and inserts “M” or “F” in the cell for the resulting gender. I haven’t programmed before, so it would be great on getting guidance on where to start. Thanks!
Answers
You would need to understand the structure of the web pages involved. Page structures are defined by the Document Object Model. It is a hierarchical structure that allows programs to address the parts that make up the page. Your page will include a form which will usually have a name but can also be referred to by an index number. In that form there will be fields...
11:45 Sun 12th May 2013
I think the easiest thing to do would be to use the VLOOKUP function as you've mentioned, and just add the unknown names to your lookup list as required, if there isn't a lot of them - that's how I would do it, anyway. It seems very convoluted to do it via a website lookup, and a lot more complicated, especially if you haven't done any programming. Also, how will you distinguish between unisex names such as Andrea, Alex, etc?
@Aquariel:
I apologize: I forgot to mention that this database is constantly being updated, so in the long run, writing code to cover the unknown names seems like the best option.
It isn't a perfect system: there will always be a margin of error, which is fine with me. The database actually takes these unisex names into account and designates them with a U, alerting me to names that I need to look up manually.
I apologize: I forgot to mention that this database is constantly being updated, so in the long run, writing code to cover the unknown names seems like the best option.
It isn't a perfect system: there will always be a margin of error, which is fine with me. The database actually takes these unisex names into account and designates them with a U, alerting me to names that I need to look up manually.
You would need to understand the structure of the web pages involved. Page structures are defined by the Document Object Model. It is a hierarchical structure that allows programs to address the parts that make up the page.
Your page will include a form which will usually have a name but can also be referred to by an index number. In that form there will be fields similarly designated. There will also be buttons which have actions, like Submit.
Your code will have to find or open an instance of the browser then address the document via the DOM structure to write the name you are searching into the appropriate form field then click the button.
Then it needs to detect that the page is replaced by the result page and similarly work through that page structure to read the result from a particular "Div" which holds the result.
Right click on the page and select View Source to see the page structure.
Here is an example of VBA code to fill in a form on a website.
http:// www.xtr emevbta lk.com/ showpos t.php?p =973120
Your page will include a form which will usually have a name but can also be referred to by an index number. In that form there will be fields similarly designated. There will also be buttons which have actions, like Submit.
Your code will have to find or open an instance of the browser then address the document via the DOM structure to write the name you are searching into the appropriate form field then click the button.
Then it needs to detect that the page is replaced by the result page and similarly work through that page structure to read the result from a particular "Div" which holds the result.
Right click on the page and select View Source to see the page structure.
Here is an example of VBA code to fill in a form on a website.
http://
-- answer removed --
Related Questions
Sorry, we can't find any related questions. Try using the search bar at the top of the page to search for some keywords, or choose a topic and submit your own question.