+ Reply to Thread
Results 1 to 3 of 3

Insert Row Macro Help

Hybrid View

ksp Insert Row Macro Help 01-16-2006, 03:25 AM
Guest Re: Insert Row Macro Help 01-16-2006, 05:10 AM
ksp Hi Interestingly enough... 01-16-2006, 05:39 AM
  1. #1
    Registered User
    Join Date
    02-18-2004
    Posts
    71

    Insert Row Macro Help

    Hi All

    I am trying to create a macro that will automatically insert one row before any cell in a specified range of Column A that contains any text (the text is free form user defined so I am unable to search just for a specific text string, and there may be blank cells in this column, with related data in other columns).

    I found the following code which is inserting rows

    Sub InsertRows()
    With Range("A11:A2498")
    Set C = .Find(What:="*", LookIn:=xlValues)
    If Not C Is Nothing Then
    firstAddress = C.Address
    Do
    C.Offset(1, 0).EntireRow.Insert
    Set C = .FindNext(C)
    Loop While Not C Is Nothing And C.Address <> firstAddress
    End If
    End With
    End Sub

    However, it seems to go on forever in a never ending loop, and I am not sure what I need to change / add to fix the problem

    Any help would be appreciated

    Thanks
    Karen

  2. #2
    Bob Phillips
    Guest

    Re: Insert Row Macro Help

    It works fine for me with the data that I created. Can you cut it back to a
    smaller range with a smaller set of data until it stops failing, thereby
    finding a manageable set of data that fails, then post that data.

    --

    HTH

    RP
    (remove nothere from the email address if mailing direct)


    "ksp" <ksp.21pv80_1137396606.0334@excelforum-nospam.com> wrote in message
    news:ksp.21pv80_1137396606.0334@excelforum-nospam.com...
    >
    > Hi All
    >
    > I am trying to create a macro that will automatically insert one row
    > before any cell in a specified range of Column A that contains any text
    > (the text is free form user defined so I am unable to search just for a
    > specific text string, and there may be blank cells in this column, with
    > related data in other columns).
    >
    > I found the following code which is inserting rows
    >
    > Sub InsertRows()
    > With Range("A11:A2498")
    > Set C = .Find(What:="*", LookIn:=xlValues)
    > If Not C Is Nothing Then
    > firstAddress = C.Address
    > Do
    > C.Offset(1, 0).EntireRow.Insert
    > Set C = .FindNext(C)
    > Loop While Not C Is Nothing And C.Address <>
    > firstAddress
    > End If
    > End With
    > End Sub
    >
    > However, it seems to go on forever in a never ending loop, and I am not
    > sure what I need to change / add to fix the problem
    >
    > Any help would be appreciated
    >
    > Thanks
    > Karen
    >
    >
    > --
    > ksp
    > ------------------------------------------------------------------------
    > ksp's Profile:

    http://www.excelforum.com/member.php...fo&userid=6267
    > View this thread: http://www.excelforum.com/showthread...hreadid=501589
    >




  3. #3
    Registered User
    Join Date
    02-18-2004
    Posts
    71
    Hi

    Interestingly enough if I copy the data and the macro as is, into a new worksheet, it works fine, even with the large data range that I am using - so apparently the macro is not to blame but something else.

    Thanks for checking my code, at least I know that it's not the problem. I'll just have to keep trying to get to the bottom of it

    Thanks
    KP

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1