LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 96
Default Delete certain accounts

Joel supplied me with the following macro to clear accounts beginning with R.
Now I discover that I need to delete all accounts which contain an R.
Can someone help?

I am also attaching and example of my worksheet.

VB code:

Sub ClearAccounts()
Lastrow = ActiveSheet.Cells.SpecialCells(xlCellTypeLastCell) .Row
LastCol = Cells(6, Columns.Count).End(xlToRight).Column
RowCount = Lastrow
Do While RowCount = 3
DeletedCells = False
For ColCount = 1 To LastCol Step 4
If Left(Cells(RowCount, ColCount), 1) = "R" Then
Set DeleteRange = Range(Cells(RowCount, ColCount), _
Cells(RowCount, ColCount + 2))
DeleteRange.Delete shift:=xlShiftUp
DeletedCells = True
End If
Next ColCount
If DeletedCells = False Then
RowCount = RowCount - 1
End If
Loop

End Sub

Example Worksheet:
A B C
1 HEADER ROW
2 "
3 "
4 "
5 "BLANK ROW"
6 Account L S
7 PF039 4
8 ROO43 1
9 PF045 1
10 QFF12 1
11 091 R0800 4
12 QG046 1
13 QG082 2
14 098 R0076 6
15 QI802 4
15 R1023 2

 
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
Transfer between accounts (worksheets) LuckyCharm Excel Discussion (Misc queries) 0 January 3rd 09 08:55 PM
Accounts functions philn Excel Worksheet Functions 4 December 22nd 08 02:58 PM
Excel for Accounts Newtonboy Excel Discussion (Misc queries) 1 July 8th 06 08:03 PM
Where can I get a general template for T-accounts CAJE Setting up and Configuration of Excel 0 December 1st 05 01:38 AM
Setting up to do my accounts (very newbie!) Ron O'Brien New Users to Excel 3 September 23rd 05 07:26 PM


All times are GMT +1. The time now is 10:09 PM.

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

About Us

"It's about Microsoft Excel"