Jessica Donadio said:
This is precisely what I am aiming to do. I want to base all the proceeding
information on the city I input in row E. . . .
You need to be more careful with terminology. E is a column, not a
row.
Presumably you mean you want to base other columns in the same row on
the city you enter in column E of that row using the information
previously entered.
. . . However, when I tried the formula,
excel is saying that the cell which the formula references is empty. . . .
It could be. If you insert ENTIRE rows, then there'll be no formulas
in any of the cells in those inserted rows in any column.
Alternatively, if you enter a city in column E for which the topmost
preceding entry for that city has no country entered, then Excel would
be correctly returning a blank cell.
. . . Are the placement of the absolute positioning signs important? . .. .
If you mean you didn't enter the formula I provided in my previous
response EXACTLY as I wrote it and/or didn't put it in cell H230, then
why not try to put my formula EXACTLY AS I WROTE IT in cell H230, then
copy H230 up if there are any blank cell in column H above it, then
copy it down as far as needed?
In other words, yes, the formula I provided contained everything I
believe is necessary and nothing superfluous. DON'T ALTER IT.
. . . Should I be including E230 somewhere in the formula? . . .
No.
The formula is meant to work if you insert cells in column E.
Precisely in order to work when cells are inserted, it's NECESSARY to
AVOID referring to INDIVIDUAL cells in column E.
However, I was guessing that you were inserting cells or rows because
you wrote the following: 'when I make a new record and insert the
city'. You probably didn't mean 'insert' in the sense of the Insert >
Cells menu command. You probably meant you were just entering data.
To repeat, you need to be more careful with terminology.
. . . I should also point out that initially the record will be on the bottom.
But if the company happens to begin with an "A", it will subsequently be moved
towards the top. . . .
And now there's company in column A.
At this point, since it seems highly likely there'd be several more
points you haven't mentioned, I'd suggest not worrying at first about
autopopulating anything. Just enter the cells that would contain data
that wouldn't have appeared already in other cells, including city but
not country. Once you have all that entered, sort your table first by
country then by city. If all the country cells are blank, this would
be equivalent to sorting by city only. If the first (topmost) record
were in row 3 (modify as needed based on the topmost row in your
table, since you haven't said I get to use something convenient for
me), then enter the following formula in cell H4 - YES! H4 *NOT* H3.
H4:
=INDEX(H$3:H3,MATCH($E4,$E$3:$E3,0))
Then fill H4 down as far as needed. For example, if your table's last
record was in row 1500, then fill H4 down into H5:H1500. You'll need
to enter the country in cell H3 for the city in E3, but there's no way
around this since there'd be no previous records to which to refer.
These formulas will evaluate to #N/A if you haven't yet entered the
country for the corresponding city, but once you enter the country for
a given city, then if you have automatic calculation enabled all
subsequent rows containing the same city in column E will have the
correct country appear in column H. Any instances of #N/A in column H
mean you have no entry for the city in column E in any previous row.
Once you've entered the countries once for every city, you should have
no more #N/A values appearing in column H. At that point, select the
entire column H range, in my example H3:H1500, and run in succession
Edit > Copy and Edit > Paste Special, Values to convert the remaining
formulas into values.
Then sort the table however you want.