Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Comparing and deleting duplicate cells

I am trying to compare the contents of a cell and the one below it. If it
is the same then delete the upper one.Have come up with this (please don't
laugh):

For cellcount = 1 To 500
If Cells(B, cellcount) = Cells(B, cellcount + 1) Then
Cells(B, cellcount).Delete (xlShiftUp)
End If
Next

Have absolutely no idea about Excel Macro's but am keen to learn, in fact
this is my first shot so if someone could help with answers in one
syllable!!

FIA

David Jacobs


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Comparing and deleting duplicate cells

Work from the bottom up.

Cells object takes rows, column arguments, not the other way, and if you use
a column letter it must be in quotes

For cellcount = 500 To 1
If Cells(cellcount,"B")= Cells(cellcount + 1,"B") Then
Cells(cellcount,"B").Delete (xlShiftUp)
End If
Next


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"David Jacobs" wrote in message
...
I am trying to compare the contents of a cell and the one below it. If it
is the same then delete the upper one.Have come up with this (please don't
laugh):

For cellcount = 1 To 500
If Cells(B, cellcount) = Cells(B, cellcount + 1) Then
Cells(B, cellcount).Delete (xlShiftUp)
End If
Next

Have absolutely no idea about Excel Macro's but am keen to learn, in fact
this is my first shot so if someone could help with answers in one
syllable!!

FIA

David Jacobs




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 430
Default Comparing and deleting duplicate cells

David, your going to have to add "Step -1" to the end of line 1 below, like
For cellcount = 500 To 1 Step -1
or code will not run.
JMay

"Bob Phillips" wrote in message
...
Work from the bottom up.

Cells object takes rows, column arguments, not the other way, and if you

use
a column letter it must be in quotes

For cellcount = 500 To 1
If Cells(cellcount,"B")= Cells(cellcount + 1,"B") Then
Cells(cellcount,"B").Delete (xlShiftUp)
End If
Next


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"David Jacobs" wrote in message
...
I am trying to compare the contents of a cell and the one below it. If

it
is the same then delete the upper one.Have come up with this (please

don't
laugh):

For cellcount = 1 To 500
If Cells(B, cellcount) = Cells(B, cellcount + 1) Then
Cells(B, cellcount).Delete (xlShiftUp)
End If
Next

Have absolutely no idea about Excel Macro's but am keen to learn, in

fact
this is my first shot so if someone could help with answers in one
syllable!!

FIA

David Jacobs






  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Comparing and deleting duplicate cells

Oops, thanks Jim (that will teach me to air-code as Rob Bovey said)

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Jim May" wrote in message
news:39wFc.20576$mN3.2727@lakeread06...
David, your going to have to add "Step -1" to the end of line 1 below,

like
For cellcount = 500 To 1 Step -1
or code will not run.
JMay

"Bob Phillips" wrote in message
...
Work from the bottom up.

Cells object takes rows, column arguments, not the other way, and if you

use
a column letter it must be in quotes

For cellcount = 500 To 1
If Cells(cellcount,"B")= Cells(cellcount + 1,"B") Then
Cells(cellcount,"B").Delete (xlShiftUp)
End If
Next


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"David Jacobs" wrote in message
...
I am trying to compare the contents of a cell and the one below it.

If
it
is the same then delete the upper one.Have come up with this (please

don't
laugh):

For cellcount = 1 To 500
If Cells(B, cellcount) = Cells(B, cellcount + 1) Then
Cells(B, cellcount).Delete (xlShiftUp)
End If
Next

Have absolutely no idea about Excel Macro's but am keen to learn, in

fact
this is my first shot so if someone could help with answers in one
syllable!!

FIA

David Jacobs








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
Deleting/Clearing duplicate range of cells Steve Excel Worksheet Functions 0 April 28th 10 03:59 PM
Deleting Duplicate cells function Vanessa Excel Discussion (Misc queries) 1 November 4th 08 06:19 PM
Deleting Duplicate Cells in one Column. Jamie Excel Discussion (Misc queries) 6 November 20th 07 04:40 PM
deleting duplicate cells in several columns bullseye Excel Worksheet Functions 4 December 5th 06 04:49 PM
Comparing ranges and deleting sktnggtr Excel Worksheet Functions 0 September 13th 05 04:01 PM


All times are GMT +1. The time now is 09:31 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"