hylw
06-15-2005, 09:50 PM
Hello, i face some problem in the following coding :bug: :
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
testArrange Target.row, Target.Column
End Sub
Public Sub testArrange(ByVal lRow As Integer, ByVal iCol As Integer)
......
......
If lRow >= startRow1ER(c) And lRow < curRow2ER Then
If Cells(lRow, iCol).Formula <> vbNullString Then
Cells(curRow1ER, curCol).Formula = Cells(lRow, iCol).Formula
Cells(curRow1ER, curCol).BorderAround ColorIndex:=22, Weight:=xlMedium
Cells(curRow1ER, curCol).WrapText = True
Cells(curRow1ER, curCol).VerticalAlignmenr = xlCenter
* Cells(curRow1ER, curCol).HorizontalAlignment = xlJustify
Cells(lRow, iCol).Delete
Cells(curRow2ER, iCol).Insert
Cells(lRow, iCol - 1).Select
curRow1ER = curRow1ER + 1
curRow2ER = curRow2ER - 1
row1ItemER(c) = row1ItemER(c) + 1
row2ItemER(c) = row2ItemER(c) - 1
End If
End If
......
......
End Sub
The Sub testArrange only execute until "*" , but if i change it as following, it work correctly:
If lRow >= startRow1ER(c) And lRow < curRow2ER Then
If Cells(lRow, iCol).Formula <> vbNullString Then
Cells(curRow1ER, curCol).Formula = Cells(lRow, iCol).Formula
Cells(lRow, iCol).Delete
Cells(curRow2ER, iCol).Insert
Cells(lRow, iCol - 1).Select
curRow1ER = curRow1ER + 1
curRow2ER = curRow2ER - 1
row1ItemER(c) = row1ItemER(c) + 1
row2ItemER(c) = row2ItemER(c) - 1
Cells(curRow1ER - 1, curCol).BorderAround ColorIndex:=22, Weight:=xlMedium
Cells(curRow1ER - 1, curCol).WrapText = True
Cells(curRow1ER - 1, curCol).VerticalAlignmenr = xlCenter
Cells(curRow1ER - 1, curCol).HorizontalAlignment = xlJustify
End If
End If
Why? :dunno please advise. Thanks :bow:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
testArrange Target.row, Target.Column
End Sub
Public Sub testArrange(ByVal lRow As Integer, ByVal iCol As Integer)
......
......
If lRow >= startRow1ER(c) And lRow < curRow2ER Then
If Cells(lRow, iCol).Formula <> vbNullString Then
Cells(curRow1ER, curCol).Formula = Cells(lRow, iCol).Formula
Cells(curRow1ER, curCol).BorderAround ColorIndex:=22, Weight:=xlMedium
Cells(curRow1ER, curCol).WrapText = True
Cells(curRow1ER, curCol).VerticalAlignmenr = xlCenter
* Cells(curRow1ER, curCol).HorizontalAlignment = xlJustify
Cells(lRow, iCol).Delete
Cells(curRow2ER, iCol).Insert
Cells(lRow, iCol - 1).Select
curRow1ER = curRow1ER + 1
curRow2ER = curRow2ER - 1
row1ItemER(c) = row1ItemER(c) + 1
row2ItemER(c) = row2ItemER(c) - 1
End If
End If
......
......
End Sub
The Sub testArrange only execute until "*" , but if i change it as following, it work correctly:
If lRow >= startRow1ER(c) And lRow < curRow2ER Then
If Cells(lRow, iCol).Formula <> vbNullString Then
Cells(curRow1ER, curCol).Formula = Cells(lRow, iCol).Formula
Cells(lRow, iCol).Delete
Cells(curRow2ER, iCol).Insert
Cells(lRow, iCol - 1).Select
curRow1ER = curRow1ER + 1
curRow2ER = curRow2ER - 1
row1ItemER(c) = row1ItemER(c) + 1
row2ItemER(c) = row2ItemER(c) - 1
Cells(curRow1ER - 1, curCol).BorderAround ColorIndex:=22, Weight:=xlMedium
Cells(curRow1ER - 1, curCol).WrapText = True
Cells(curRow1ER - 1, curCol).VerticalAlignmenr = xlCenter
Cells(curRow1ER - 1, curCol).HorizontalAlignment = xlJustify
End If
End If
Why? :dunno please advise. Thanks :bow: