Thread
:
Copy Paired Info to Different number of Rows
View Single Post
#
2
Posted to microsoft.public.excel.programming
Chris
external usenet poster
Posts: 244
Copy Paired Info to Different number of Rows
Use the currentregion property. This will always bring back all the filled cells in an area
For instance as long as column A has countiguous data in rows 1 - 10 and column B thru D all have data at least in row 1 then the Currentregion will be A1:D10
so you can do this
dim x as long, MyRange as Range, C as Rang
range("A1").selec
x = selection.currentregion.rows.coun
set myrange = range(cells(1,1), cells(x,1)) " this is all filled cells in Column A
For each c im MyRang
"do your code and changes here
" you can use the Offset method to traverse other columns within the same row and make updates.
Nex
-----
wrote: ----
I am working on old county migration flow datasets
The datasets are for in-migration into a specific county
For example, a typical file includes many in-migration
counties
C D E F
St. FIPS Name # of return
30 017 Custer 1
30 111 Yellowstone
30 031 Gallatin
Same State
Diff Region
30 017 County Non-Migrants 1
30 019 Daniels 1
30 162 Missula
30 033 King
30 031 Gallatin
Same State
Diff Region
30 019 County Non-Migrants 1
I want to make a macro that takes the first numbers by the
cell right below a "County Non-Migrants" and copies them
to the next "County Non-Migrants," taking into account
that the number of rows is not constant
Example of End Result
A B C D E F
To To Fro
St. FIPS St. FIPS Name # of return
30 017 30 017 Custer 1
30 017 30 111 Yellowstone
30 017 30 031 Gallatin
30 017 Same State
30 017 Diff Region
30 017 30 017 County Non-Migrants 1
30 019 30 019 Daniels 1
30 019 30 162 Missula
30 019 30 033 King
30 019 30 031 Gallatin
30 019 Same State
30 019 Diff Region
30 019 30 019 County Non-Migrants 1
The problem I see is that the rows are not constant. How
would you write a complex if statement to take into
account the "county non-migrants" information
Thanks for your help. (By the way, I have thousands rows
of cells of this type of information for over 10 years
with cells for each county in three states. A lot of work
for a long time if I have to the procedure manually.
Reply With Quote
Chris
View Public Profile
Find all posts by Chris