Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
problem moving columns around
All,
I need to re-order some columns in Worksheet. Here is the code which works just fine (to a point): ...... For fldCnt = 0 To numOfFlds - 1 ' Check every name in the first row ' For colNum = 1 To numOfCols fldVal = wks.Cells(rowFirst, colNum).Value If fldList(fldCnt) = fldVal Then If colNum < (found + 1) Then ' Column needs to be moved to 'curPos' ' Set rngColToMove = wks.Range(wks.Cells(rowFirst, colNum), wks.Cells(rowLast, colNum)) Set rngDst = wks.Range(wks.Cells(rowFirst, curPos), wks.Cells(rowLast, curPos)) Range(rngColToMove.Address).Select Selection.Cut Range(rngDst.Address).Select Selection.Insert (xlShiftToRight) curPos = curPos + 1 End If found = found + 1 Exit For End If Next colNum Next fldCnt ...... The problem is that when I move the column the contents of "wks.Cells(rowFirst, colNum)" does not change to reflect the column's movement.. In other words, if the original column order is a,b,c,d and I change it to d,a,b,c what I see in the first row, programmatically, is still a,b,c,d. It is as though I need some sore of "refresh" after I do the cut/paste. I tried making it a Range object and then resetting it after the cut/paste, but the order was still a,b,c,d. Any ideas? TIA, Bill |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Moving columns with formulas gives #REF! | Excel Worksheet Functions | |||
Moving Columns | Excel Discussion (Misc queries) | |||
Moving columns about | Excel Programming | |||
Moving Columns only | Excel Programming | |||
Moving Columns | Excel Programming |