Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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" wrote in message
...
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
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Code to include a one-up suffix to a field value Doctorjones_md Excel Discussion (Misc queries) 4 January 4th 07 06:18 PM
Code to include a one-up suffix to a field value Doctorjones_md Excel Worksheet Functions 4 January 4th 07 06:18 PM
Include a password in VB code. GA Excel Discussion (Misc queries) 6 March 23rd 06 07:36 AM
How do I include wsh or vbs code/script in an Excel macro Naived Merchant Excel Programming 1 May 27th 04 02:38 PM
How do I include a wider range in my code?? nrage21[_10_] Excel Programming 4 January 22nd 04 08:49 PM


All times are GMT +1. The time now is 02:40 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"