PDA

View Full Version : Search for the string and move the cells accordingly



kittykat
05-10-2007, 10:43 AM
Hi,

I need to run a report for my school. I need to do a For loop where I need to search Number of activities in the page and move it to right or left depending on the user choice by one cell .

Any help on how to code it.

Have attached a sample.

Simon Lloyd
05-10-2007, 11:35 AM
KittyKat, your workbook does not explain anything!, why dont you try turning on the macro recorder, perform your actions, and then see what code has been generated....you may well be able to manipulate most of the code yourself, when you have something on the way to what you want we will all probably have a better idea of what you are trying to achieve!

Paul_Hossler
05-11-2007, 08:23 AM
This makes the first sheet look like your second sheet

I hope that's what you were looking for

By the way, "Activiities" is mis-spelt :devil2: (since this was school related, I couldn't resist)



Sub ShiftCells()
Dim rData As Range, rCell As Range

Application.ScreenUpdating = False

Set rData = ActiveSheet.UsedRange
For Each rCell In rData.Columns(1).Cells
If Left(rCell.Value, 3) = "No." Then rCell.Insert (xlShiftToRight)
Next
End Sub