Delete Cells in Excel Row based on number in Cell

Allen2014

New Member
Joined
Dec 8, 2014
Messages
5
I have the following data and would like some VBA Code to run down the Rows and based on the number in Column D, Delete the Cells (and Shift Data to the Left) in Columns E to I based on the number in Column D. For example,
In Row 1, to delete Cells F1:I1, as the value is 1; Value retained = "Item1"
In Row 2, to delete Cells in E2 then Cells F2:I2; Value retained = "Item2"
In Row 3, to delete Cells in E3:F3 then Cells F3:I3; Value retained = "Item3"
In Row 4, to delete Cells in F4:I4; and so on ... Value retained = "Item1"
At the end I want only one of the items in Columns E:I in each of the Rows, with the number oin Column D determining which of the Columns Data is retained.
Max number of Columns holding data to be retained is 5, hence looking in Columns E:I, although this may be a variable.
Any assistance is much appreciated.
Thanks
Allen



-- removed inline image ---



<colgroup><col><col><col><col><col span="5"></colgroup><tbody>
</tbody>
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).

Forum statistics

Threads
1,216,084
Messages
6,128,724
Members
449,465
Latest member
TAKLAM

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