PDA

View Full Version : Solved: Reformatting a WorkSheet



Saladsamurai
09-01-2009, 10:46 AM
:hi: Hello there.


I have attached a small sample wrkbk.

Originally Sheet ! and Sheet 2 each conatined rows of the exact same length. This is because each Sheet is used to keep track of a particular property of a data center item.

On sheet 1 we have the power and on sheet 2 we have its performance.

I have manually gone into Sheet 1 and placed the "$" symbol in certain locations to make future coding easier.

Now I would like to make Sheet 2 follow suit. That is, I need a to write a code that will look at Sheet 1 and insert a "$" symbol onto Sheet 2 wherever necessary and then "shift" the data on sheet 2 accordingly.

Sheet 3 shows the desired effect done by hand.

Thanks!

Saladsamurai
09-01-2009, 11:24 AM
I believe, as in efficient as it may be, this works. I tested it on the sample book. I just need to write a quick check.
Sub Test()
For i = 1 To 3
For j = 1 To 32

If Worksheets("Sheet1").Cells(i, j) = "$" Then
Worksheets("Sheet2").Cells(i, j).Insert Shift:=xlToRight
Worksheets("Sheet2").Cells(i, j) = Worksheets("Sheet1").Cells(i, j)
End If




Next j
Next i
End Sub

Saladsamurai
09-02-2009, 05:06 AM
Can Anyone see why this would be failing me?

It works on my first WorkSheet, but then things get kind of whacky on the others??