shift cells to the left

marc005

Board Regular
Joined
Apr 21, 2013
Messages
58
My worksheet looks like this:

A B C DE F G H I J K L MN O P
7 Days Group HoldingsSVN13.5913.5913.513.54-0.05-0.3757,65713.68.1......23.9312.27
0-9 | A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z
ASymbolOpenHighLowCloseNet%ChgVol52 Week52 WeekDivYieldPEYTD
ChgHighLow%Chg
AAR Corp.AIR16.5616.6216.0216.52......343,43520.44100.31.829.72-11.56
Aaron's Inc.AAN28.2928.628.0328.35-0.18-0.63269,24332.5324.610.070.2412.420.25
ABB ADSABB21.3721.4221.0121.21-0.21-0.982,130,30623.3715.260.743.4818.52.02
Abbott LaboratoriesABT3737.2236.5636.89-0.31-0.835,301,33937.5528.40.561.5211.1517.71
Advanced Micro DevicesAMD2.472.512.432.46-0.01-0.414,009,3797.721.81......... dd2.5
Advanced Semiconductor Engineering ADSASX4.34.34.254.30.020.47329,3544.653.140.112.5714.810.47
Advantage Oil&GasAAV3.713.743.633.65-0.06-1.62110,5254.22.47......... dd12.65
Advantest Corp ADSATE13.9414.0413.8613.94-0.25-1.769,35717.2510.8......51.1-13.52
AECOM TechnologyACM28.3828.8627.7128.590.371.31838,63233.0914.5......... dd20.13
Aegean Marine Petroleum NetworkANW5.875.965.745.91......63,2417.884.280.040.6813.7411.93
Aegon NV ADSAEG5.915.945.815.920.020.34643,5596.953.930.294.966.59-8.07
AerCap HoldingsAER15.315.415.1715.29......361,51616.5710.6......12.7411.44
Aeroflex HoldingARX7.097.197.027.180.040.5622,56311.55......... dd2.57
ASymbolOpenHighLowCloseNet%ChgVol52 Week52 WeekDivYieldPEYTD
ChgHighLow%Chg
AeropostaleARO13.0513.2212.6413.04-0.01-0.081,551,79923.0511.76......30.260.23
AESAES12.8813.0112.712.920.050.393,836,38213.29.520.161.24... dd20.75
AetnaAET55.8855.8854.8855.02-0.85-1.521,909,30956.9234.580.81.4511.3218.81

<tbody>
</tbody>


You can see that for some reason the rows that has a value in column P has been shifted one step to the right. How can I correct this?
Preferably I a loop that checks if cell(i,16) has a value then shift the row one step to the left. Also there are more rows than shown above.
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
Code:
[color=darkblue]Sub[/color] P_Shift()
    [color=darkblue]Dim[/color] cell   [color=darkblue]As[/color] Range
    Application.ScreenUpdating = [color=darkblue]False[/color]
    [color=darkblue]For[/color] [color=darkblue]Each[/color] cell [color=darkblue]In[/color] Range("P:P").SpecialCells(xlCellTypeConstants)
        Range("A" & cell.Row).Delete Shift:=xlShiftToLeft
    [color=darkblue]Next[/color] cell
    Application.ScreenUpdating = [color=darkblue]True[/color]
[color=darkblue]End[/color] [color=darkblue]Sub[/color]
 
Upvote 0
Thanx for your help AlphaFrog. The code works great :)
You saved me a lot of trial and error time.
 
Upvote 0

Forum statistics

Threads
1,216,119
Messages
6,128,946
Members
449,480
Latest member
yesitisasport

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top