+ Reply to Thread
Results 1 to 4 of 4

Code to NOT include row 1 and 2

  1. #1
    Annette
    Guest

    Code to NOT include row 1 and 2

    I use this code to remove nonbolded items ... but now I realize it can not
    and should not touch headings which happen to be in row 1 and 2. Can
    someone tell me what should be written so it doesn't touch those two rows?

    Sub RemoveNonBoldedRows()
    Dim i As Long
    With ActiveSheet
    i = .Cells(Rows.Count, 1).End(xlUp).Row

    Do Until i < 1
    If .Cells(i, 1).Font.Bold = True Then
    i = i - 2
    Else
    .Rows(i).Delete xlShiftUp
    i = i - 1
    End If
    Loop
    End With
    Range("A1").Select

    End Sub



  2. #2
    Tom Ogilvy
    Guest

    Re: Code to NOT include row 1 and 2

    Sub RemoveNonBoldedRows()
    Dim i As Long
    With ActiveSheet
    i = .Cells(Rows.Count, 1).End(xlUp).Row

    Do Until i < 3
    If .Cells(i, 1).Font.Bold = True Then
    i = i - 2
    Else
    .Rows(i).Delete xlShiftUp
    i = i - 1
    End If
    Loop
    End With
    Range("A1").Select

    --
    Regards,
    Tom Ogilvy

    "Annette" <[email protected]> wrote in message
    news:%[email protected]...
    > I use this code to remove nonbolded items ... but now I realize it can not
    > and should not touch headings which happen to be in row 1 and 2. Can
    > someone tell me what should be written so it doesn't touch those two rows?
    >
    > Sub RemoveNonBoldedRows()
    > Dim i As Long
    > With ActiveSheet
    > i = .Cells(Rows.Count, 1).End(xlUp).Row
    >
    > Do Until i < 1
    > If .Cells(i, 1).Font.Bold = True Then
    > i = i - 2
    > Else
    > .Rows(i).Delete xlShiftUp
    > i = i - 1
    > End If
    > Loop
    > End With
    > Range("A1").Select
    >
    > End Sub
    >
    >




  3. #3
    Don Guillett
    Guest

    Re: Code to NOT include row 1 and 2

    try this
    Sub deletebolded()
    For i = Cells(Rows.Count, 1).End(xlUp).row To 3 Step -1
    If Cells(i, 1).Font.Bold Then Rows(i).Delete
    Next
    End Sub

    --
    Don Guillett
    SalesAid Software
    [email protected]
    "Annette" <[email protected]> wrote in message
    news:%[email protected]...
    > I use this code to remove nonbolded items ... but now I realize it can not
    > and should not touch headings which happen to be in row 1 and 2. Can
    > someone tell me what should be written so it doesn't touch those two rows?
    >
    > Sub RemoveNonBoldedRows()
    > Dim i As Long
    > With ActiveSheet
    > i = .Cells(Rows.Count, 1).End(xlUp).Row
    >
    > Do Until i < 1
    > If .Cells(i, 1).Font.Bold = True Then
    > i = i - 2
    > Else
    > .Rows(i).Delete xlShiftUp
    > i = i - 1
    > End If
    > Loop
    > End With
    > Range("A1").Select
    >
    > End Sub
    >
    >




  4. #4
    Don Guillett
    Guest

    Re: Code to NOT include row 1 and 2

    try
    for i =2 to .Cells(Rows.Count, 1).End(xlUp).Row
    code
    next

    --
    Don Guillett
    SalesAid Software
    [email protected]
    "Annette" <[email protected]> wrote in message
    news:%[email protected]...
    > I use this code to remove nonbolded items ... but now I realize it can not
    > and should not touch headings which happen to be in row 1 and 2. Can
    > someone tell me what should be written so it doesn't touch those two rows?
    >
    > Sub RemoveNonBoldedRows()
    > Dim i As Long
    > With ActiveSheet
    > i = .Cells(Rows.Count, 1).End(xlUp).Row
    >
    > Do Until i < 1
    > If .Cells(i, 1).Font.Bold = True Then
    > i = i - 2
    > Else
    > .Rows(i).Delete xlShiftUp
    > i = i - 1
    > End If
    > Loop
    > End With
    > Range("A1").Select
    >
    > End Sub
    >
    >




+ 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