ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Move data to right with variable rows (https://www.excelbanter.com/excel-programming/438640-move-data-right-variable-rows.html)

Hondavtx

Move data to right with variable rows
 
I have a large spreadsheet with corrupted data. I can identify several types
of bad data and have correct the data in these rows but one particluar type
is giving me problems.

Because the spreadsheet is large I used filtering and visible cell commands
to correct blocks of data. This seems to work fine but one type is still not
working so I am trying a row by row logic search. In this case the bad data
needs to move from cell column B to C with the range through L. So any data
in the range B through L in the selected row is copied if the contents of L
="N". A cell is inserted at B and the data shifted to the right by one cell.
The rows is a variable. and I have a header at the top to ignore.

My Code at the moment looks like this

With ActiveSheet
Dim pointer As Long
For pointer = .UsedRange.Rows.Count To 2 Step -1
If .Cells(pointer, "L") = "N" Then
Range("B" & pointer).Select
Selection.Insert Shift:=xlToRight, _
CopyOrgin:=xlFormatFromLeftOrAbove
End If
Next
End With

This does not work and will also be slow. Any Suggestions?


All times are GMT +1. The time now is 06:26 AM.

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