Consulting

Results 1 to 3 of 3

Thread: Search for the string and move the cells accordingly

  1. #1

    Search for the string and move the cells accordingly

    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.

  2. #2
    Moderator VBAX Guru Simon Lloyd's Avatar
    Joined
    Sep 2005
    Location
    UK
    Posts
    3,003
    Location
    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!
    Regards,
    Simon
    Please read this before cross posting!
    In the unlikely event you didn't get your answer here try Microsoft Office Discussion @ The Code Cage
    If I have seen further it is by standing on the shoulders of giants.
    Isaac Newton, Letter to Robert Hooke, February 5, 1675 English mathematician & physicist (1642 - 1727)

  3. #3
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,729
    Location
    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 (since this was school related, I couldn't resist)

    [VBA]

    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
    [/VBA]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •