ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   'Moving cells' (https://www.excelbanter.com/excel-programming/404428-moving-cells.html)

Mac

'Moving cells'
 
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!

joel

'Moving cells'
 

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

"Mac" wrote:

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!



All times are GMT +1. The time now is 04:59 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com