'Moving cells'

M

Mac

Situation: area - 100 rows x 50 cols; cell contents - there are only 1's
scattered throughout the whole area, like: row 3 contains the no. 1 in cells
B, D,E, AB, CD, row 10 contains no. 1 in cells D,F, AB, CC, FG, ... - what's
important here is the concept, not the positioning; an agregate row (e.g.
101) contains the sum of all 1's above for each column (here the sum would be
1 for col B, 2 for col D, 1 for col E, 1 for col F, 2 for col AB, ...); so
much for the 'static' situation and I hope it's pretty straightforward. Now,
important are the sums in R101 in correspondence to positions of the 1's - I
need to b able to 'shift' a whole row to change the sums in R101, like this:
select e.g. row 3 and press Ctrl+L which runs a code that would take all 1's
in the selected row and shift them one cell to the left, and see how the sums
in R101 changed; if the change is not ok, repeat this for a different row,
etc. Is someone willing to provide me with a piece of at least a sample code
to achieve this? Thanks a lot!
 
J

Joel

RowCount = activecell.row
LastCol = Range(""FG").Column
for Colcolumn = 2 to LastCol
if cells(RowCount,Colcount) = 1 then
cells(RowCount,Colcount) = ""
cells(RowCount,Colcount - 1) = 1
end if
next Colcolumn
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top