Hello all,
What I have is a small range with 5 rows and 2 columns. What I would like to do is turn this:
[TABLE="class: tableizer-table"]
<tbody>[TR="class: tableizer-firstrow"]
[TH="bgcolor: #104E8B"][/TH]
[TH="bgcolor: #104E8B"][/TH]
[/TR]
[TR]
[TD]Deposit A[/TD]
[TD]100.00[/TD]
[/TR]
[TR]
[TD]x[/TD]
[TD]x[/TD]
[/TR]
[TR]
[TD]x[/TD]
[TD]x[/TD]
[/TR]
[TR]
[TD]Deposit B[/TD]
[TD]200.00[/TD]
[/TR]
[TR]
[TD]Deposit C[/TD]
[TD]300.00[/TD]
[/TR]
</tbody>[/TABLE]
Into this:
[TABLE="class: tableizer-table"]
<tbody>[TR="class: tableizer-firstrow"]
[TH="bgcolor: #104E8B"][/TH]
[TH="bgcolor: #104E8B"][/TH]
[/TR]
[TR]
[TD]Deposit A[/TD]
[TD]100.00[/TD]
[/TR]
[TR]
[TD]Deposit B[/TD]
[TD]200.00[/TD]
[/TR]
[TR]
[TD]Deposit C[/TD]
[TD]300.00[/TD]
[/TR]
[TR]
[TD]x[/TD]
[TD]x[/TD]
[/TR]
[TR]
[TD]x[/TD]
[TD]x[/TD]
[/TR]
</tbody>[/TABLE]
However, I do not want to actually MOVE any cells by cutting/pasting or sorting. I only want the values to be shifted around.
My first thought would be to go through each row in the range and determine if it's blank, and if so then copy the values up from the row below, then clear that copied row of it's data and continue the check.
However, if I write it to run through each row in the range one time then I imagine it would come up like this:
[TABLE="class: tableizer-table"]
<tbody>[TR="class: tableizer-firstrow"]
[TH="bgcolor: #104E8B"][/TH]
[TH="bgcolor: #104E8B"][/TH]
[/TR]
[TR]
[TD]Deposit A[/TD]
[TD]100.00[/TD]
[/TR]
[TR]
[TD]x[/TD]
[TD]x[/TD]
[/TR]
[TR]
[TD]Deposit B[/TD]
[TD]200.00[/TD]
[/TR]
[TR]
[TD]Deposit C[/TD]
[TD]300.00[/TD]
[/TR]
[TR]
[TD]x[/TD]
[TD]x[/TD]
[/TR]
</tbody>[/TABLE]
I suppose I could have it run through the check several times to ensure that all of the data has been moved up, but I know there has to be a better way.
What I would like to write, but don't know how, would be something like:
Step 1: Evaluate the rows in the given range.
Step 2: "Save" any row that has at least one non-blank value in it. Ignore all the completely blank rows.
Step 3: Probably also count the number of rows "saved" in step 2.
Step 4: Input the "saved" rows/values at the top of the range.
Step 5: Beginning with the row Count + 1, clear the values from there to the end of the range.
Also, please note that this 5x2 range has other data to the sides of it that I do not want to be effected.
Not that I would turn it down, but I'm not asking for this sub to be written out in full for me.
All I am asking is if you know of any clever ways to preform any part of this process then please let me know and point me in the right direction!
Thank you,
Grummet
What I have is a small range with 5 rows and 2 columns. What I would like to do is turn this:
[TABLE="class: tableizer-table"]
<tbody>[TR="class: tableizer-firstrow"]
[TH="bgcolor: #104E8B"][/TH]
[TH="bgcolor: #104E8B"][/TH]
[/TR]
[TR]
[TD]Deposit A[/TD]
[TD]100.00[/TD]
[/TR]
[TR]
[TD]x[/TD]
[TD]x[/TD]
[/TR]
[TR]
[TD]x[/TD]
[TD]x[/TD]
[/TR]
[TR]
[TD]Deposit B[/TD]
[TD]200.00[/TD]
[/TR]
[TR]
[TD]Deposit C[/TD]
[TD]300.00[/TD]
[/TR]
</tbody>[/TABLE]
Into this:
[TABLE="class: tableizer-table"]
<tbody>[TR="class: tableizer-firstrow"]
[TH="bgcolor: #104E8B"][/TH]
[TH="bgcolor: #104E8B"][/TH]
[/TR]
[TR]
[TD]Deposit A[/TD]
[TD]100.00[/TD]
[/TR]
[TR]
[TD]Deposit B[/TD]
[TD]200.00[/TD]
[/TR]
[TR]
[TD]Deposit C[/TD]
[TD]300.00[/TD]
[/TR]
[TR]
[TD]x[/TD]
[TD]x[/TD]
[/TR]
[TR]
[TD]x[/TD]
[TD]x[/TD]
[/TR]
</tbody>[/TABLE]
However, I do not want to actually MOVE any cells by cutting/pasting or sorting. I only want the values to be shifted around.
My first thought would be to go through each row in the range and determine if it's blank, and if so then copy the values up from the row below, then clear that copied row of it's data and continue the check.
However, if I write it to run through each row in the range one time then I imagine it would come up like this:
[TABLE="class: tableizer-table"]
<tbody>[TR="class: tableizer-firstrow"]
[TH="bgcolor: #104E8B"][/TH]
[TH="bgcolor: #104E8B"][/TH]
[/TR]
[TR]
[TD]Deposit A[/TD]
[TD]100.00[/TD]
[/TR]
[TR]
[TD]x[/TD]
[TD]x[/TD]
[/TR]
[TR]
[TD]Deposit B[/TD]
[TD]200.00[/TD]
[/TR]
[TR]
[TD]Deposit C[/TD]
[TD]300.00[/TD]
[/TR]
[TR]
[TD]x[/TD]
[TD]x[/TD]
[/TR]
</tbody>[/TABLE]
I suppose I could have it run through the check several times to ensure that all of the data has been moved up, but I know there has to be a better way.
What I would like to write, but don't know how, would be something like:
Step 1: Evaluate the rows in the given range.
Step 2: "Save" any row that has at least one non-blank value in it. Ignore all the completely blank rows.
Step 3: Probably also count the number of rows "saved" in step 2.
Step 4: Input the "saved" rows/values at the top of the range.
Step 5: Beginning with the row Count + 1, clear the values from there to the end of the range.
Also, please note that this 5x2 range has other data to the sides of it that I do not want to be effected.
Not that I would turn it down, but I'm not asking for this sub to be written out in full for me.
All I am asking is if you know of any clever ways to preform any part of this process then please let me know and point me in the right direction!
Thank you,
Grummet
Last edited: