Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 275
Default VB code required to compare/delete data

Hi all,

Can somebody donate some VB code to carry out the following task?

Look at name in cell BC2, check the name in cell BA2 and if is the same
delete the name in BA2 and BC2.
If is different then leave both cells as they are and move onto checking BC3
against BA3
carry this loop thru BC2 : BC40

hope this makes sense and thanks in advance
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default VB code required to compare/delete data

Sub ABC()
dim i as Long
for i = 40 to 2 step -1

if not isempty(cells(i,"BC")) then
if cells(i,"BC").Value = cells(i,"BA").Value then
' rows(i).Delete
Cells(i,"BC").ClearContents
Cells(i,"BA").ClearContents
end if
End if
Next i
End Sub

--
Regards,
Tom Ogilvy


"Anthony" wrote in message
...
Hi all,

Can somebody donate some VB code to carry out the following task?

Look at name in cell BC2, check the name in cell BA2 and if is the same
delete the name in BA2 and BC2.
If is different then leave both cells as they are and move onto checking
BC3
against BA3
carry this loop thru BC2 : BC40

hope this makes sense and thanks in advance



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 275
Default VB code required to compare/delete data

Hi Tom

Thanks for the above, but after running the macro, nothing seems to happen,
ie no names are removed from the list in column BC when it is obvious they
are also listed in column BA !


"Tom Ogilvy" wrote:

Sub ABC()
dim i as Long
for i = 40 to 2 step -1

if not isempty(cells(i,"BC")) then
if cells(i,"BC").Value = cells(i,"BA").Value then
' rows(i).Delete
Cells(i,"BC").ClearContents
Cells(i,"BA").ClearContents
end if
End if
Next i
End Sub

--
Regards,
Tom Ogilvy


"Anthony" wrote in message
...
Hi all,

Can somebody donate some VB code to carry out the following task?

Look at name in cell BC2, check the name in cell BA2 and if is the same
delete the name in BA2 and BC2.
If is different then leave both cells as they are and move onto checking
BC3
against BA3
carry this loop thru BC2 : BC40

hope this makes sense and thanks in advance




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default VB code required to compare/delete data

The code doesn't lie Anthony. Your eyes might or you might not have
correctly described your situation.

I tested the code and it worked fine for me.

Let's assume you have some spaces after the data in one column that are not
in the other.

Sub ABC()
Dim i As Long
For i = 40 To 2 Step -1

If Not IsEmpty(Cells(i, "BC")) Then
If Trim(lcase(Cells(i, "BC").Value)) = _
Trim(lcase(Cells(i, "BA").Value)) Then
' rows(i).Delete
Cells(i, "BC").ClearContents
Cells(i, "BA").ClearContents
End If
End If
Next i
End Sub

If that doesn't work, go to

BD2 and put in the formula

=BC2=BA2
and drag fill down the column. I would expect all to be false.

--
Regards,
Tom Ogilvy



"Anthony" wrote in message
...
Hi Tom

Thanks for the above, but after running the macro, nothing seems to
happen,
ie no names are removed from the list in column BC when it is obvious they
are also listed in column BA !


"Tom Ogilvy" wrote:

Sub ABC()
dim i as Long
for i = 40 to 2 step -1

if not isempty(cells(i,"BC")) then
if cells(i,"BC").Value = cells(i,"BA").Value then
' rows(i).Delete
Cells(i,"BC").ClearContents
Cells(i,"BA").ClearContents
end if
End if
Next i
End Sub

--
Regards,
Tom Ogilvy


"Anthony" wrote in message
...
Hi all,

Can somebody donate some VB code to carry out the following task?

Look at name in cell BC2, check the name in cell BA2 and if is the same
delete the name in BA2 and BC2.
If is different then leave both cells as they are and move onto
checking
BC3
against BA3
carry this loop thru BC2 : BC40

hope this makes sense and thanks in advance






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
VB code Required-------! Thyagaraj Excel Programming 1 July 17th 06 03:35 AM
VBA Code Required to Get Data Which is In Coloums Into Rows stublair Excel Programming 2 December 16th 05 04:35 PM
Delete columns not required Tempy Excel Programming 11 September 12th 05 03:31 PM
Worksheet Change code not running when you just delete data in cells. KimberlyC Excel Programming 0 June 23rd 05 01:43 AM
Code required please Neal Excel Programming 2 January 24th 05 05:27 AM


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

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"