Skip to main content
gamedev.net
🔒 Locked

Programming in Excel

Started by baddogj Jun 12, 2009 at 9:48 PM 2 replies 1.2k views
Original Post
baddogj
baddogj
Ok I'm trying to figure out the fastest way possible to code the input for the sheet I have in excel. Basically, Column C has about 1000 entries of different cities in a particular state. I'm trying to code Column F so that it'll have the correct county based on the city listed adjacent to column F in C. I don't have much experience programming in vba for excel so could someone please help? Thanks in advance.
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="88" height="70" id="H2lvl" align="middle"> <param name="allowScriptAccess" value="sameDomain" /> <param name="movie" value="http://www.ironhive.com/CFCs/H2lvl.swf?gamertag=jBaddog" /> <param name="quality" value="high" /> <param name="wmode" value="transparent"> <embed src="http://www.ironhive.com/CFCs/
_Sigma
_Sigma
Do you have an example of what this data looks like, and the desired output?
ChurchSkiz
ChurchSkiz
If you're pulling from a data table for the counties, you don't need to use VBA at all, just use a vlookup.

I suggest you go to ozgrid.com/forum for help. That's where I got all my questions answered and learned VBA when I was an Excel noob.
dmatter
dmatter
You don't need VBA for this as you can simply use a lookup table, such things are common in spreadsheets.

Somewhere in your spreadsheet you need to make a table with two columns (it can be two rows but we tend to expand vertically), in the first (left-most) column you list all the cities, in the second column you specify the county for each city; this is the lookup table and it can be hidden or located on a different sheet, anything you want.
Next you use a lookup function in the forumlae for each relevant cell down column F, if your lookup table is vertically arranged then vlookup will do the job (use hlookup if you arranged it horizontally). For the first parameter of this function specify the appropriate cell in column C, for the second parameter specify the rectangular range of the lookup table, make the third parameter equal to 2 in order to indicate that you want to return the second column and finally there is a 4th optional parameter: If your city names in the lookup table are ordered alphabetically then you can ignore this parameter altogether, either way you can specify this to be FALSE to indicate that you want an exact match.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.