Thread: Need 2 macros
View Single Post
  #10   Report Post  
Posted to microsoft.public.excel.misc
chrisnsmith chrisnsmith is offline
external usenet poster
 
Posts: 96
Default Need 2 macros

Joel,
Tried your macro, it worked great. Thanks

"Joel" wrote:

Sub clearrows()

Rows("3:" & Rows.Count).ClearContents

End Sub

Sub ClearRRows()
Lastrow = ActiveSheet.Cells.SpecialCells(xlCellTypeLastCell) .Row
LastCol = Cells(1, Columns.Count).End(xlToLeft).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





"chrisnsmith" wrote:

I need macros to perform two operations on the following example.

1. I need to delete any Accounts in columns A,E and I that begin with R.
2. I need a macro to clear the contents of the entire workbook starting at
row 3.


A B C D E F G H
I J K
1 Account Long Short Account Long Short Account Long
Short
2
3 PA037 4 PA037 4 CR237 7
4 Q1024 4 Q1024 4 PA037 4
4 Q1024 4 Q1024 4 HI012 8
5 Q2050 4 Q2050 4 R2009 5
6 Q2450 1 Q2450 1 R8912 6
7 R0000 33 R0000 33
8 R0924 4 R0924 4
9 5032 33 5032 33
10 10375 20 10375 20
11 29280 1 29280 1
12 39124 2 39124 15