Re: Clearing Contents

Tech-Archive recommends: Speed Up your PC by fixing your registry



Sean:

You could use a loop to move through the work***. Within the loop,
compare the values in column A and column B using the ActiveCell.Offset
property. If A& B are the same, then you can set the values of the second
row to "". I tested the code below and it appears to work.

For example:

Sub TestMacro()
Dim wks As Work***
Dim colA As String
Dim colB As String
Dim i As Integer

Set wks = Active***

Cells(1, 1).Select

For i = 1 To wks.Cells.CurrentRegion.Rows.Count
colA = ActiveCell.Value
colB = ActiveCell.Offset(0, 1).Value

Do Until colA <> ActiveCell.Offset(1, 0).Value And colB <>
ActiveCell.Offset(1, 1).Value
ActiveCell.Offset(1, 0) = ""
ActiveCell.Offset(1, 1) = ""
ActiveCell.Offset(1, 0).Select
i = i + 1
Loop
ActiveCell.Offset(1, 0).Select
Next i


--
David Lloyd
MCSD .NET
http://LemingtonConsulting.com

This response is supplied "as is" without any representations or warranties.


"Sean" <Sean@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:9F97C8F5-2554-4D31-869E-5026BE1DEB3D@xxxxxxxxxxxxxxxx
> I have a workbook open with about 22,000 rows in it. It has data like
this
>
> A B C D
>
> SD FRED 3 9
> SD FRED 4 2
> SD FRED 6 27
> SF SAM 3 6
> SF SAM 4 8
> SF SAM 6 1
>
> Now A and B continually shows the same info and C and D are what changes,
I
> want to clear the contents on columns A and B if it sees the same in A and
B
> twice, before jumping to the next row. So the data would look like this
when
> through
>
> A B C D
>
> SD FRED 3 9
> 4 2
> 6 27
> SF SAM 3 6
> 4 8
> 6 1
>
> Same data but it only shows me the vendor and the name once and then
> continues on with the rest of the data. Any ideas anyone!!! Thanks in
> advance
>
> Sincerely
>
> Sean
>


.


Quantcast