Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 47
Default Delete row if columnA and ColumnB are same

I have one big excel spreed sheet, on the ColumnA is call
staddr, and ColumnB is call mailaddr, if both column as
same address, example "123 main street" then I need to
delete entire row, can everyone show me how to write with
VB script. I will be really appreciated it.


Lillian
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default Delete row if columnA and ColumnB are same

Hi
try something like the following:
Sub delete_rows()
Dim RowNdx As Long
Dim LastRow As Long
Application.ScreenUpdating = False
LastRow = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).row
For RowNdx = LastRow To 1 Step -1
with Cells(RowNdx, "A")
if .value = .offset(0,1).value then
Rows(RowNdx).Delete
End If
end with
Next RowNdx
Application.ScreenUpdating = True
End Sub

--
Regards
Frank Kabel
Frankfurt, Germany


Lillian wrote:
I have one big excel spreed sheet, on the ColumnA is call
staddr, and ColumnB is call mailaddr, if both column as
same address, example "123 main street" then I need to
delete entire row, can everyone show me how to write with
VB script. I will be really appreciated it.


Lillian

  #3   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default Delete row if columnA and ColumnB are same

Why not try this using Access, much easier. Just import
the spread sheet, run a query to find matches and delete
the results. Then you can TransferSpreadSheet back out to
Excel if you need to.


-----Original Message-----
I have one big excel spreed sheet, on the ColumnA is call
staddr, and ColumnB is call mailaddr, if both column as
same address, example "123 main street" then I need to
delete entire row, can everyone show me how to write with
VB script. I will be really appreciated it.


Lillian
.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 47
Default Delete row if columnA and ColumnB are same

Thanks it work, the offset (0,1) is refer to ColumnB, am
I right? if Column A want to match to ColumnC then I need
to set the offset (0,2), am I correct?


Lillian
-----Original Message-----
Hi
try something like the following:
Sub delete_rows()
Dim RowNdx As Long
Dim LastRow As Long
Application.ScreenUpdating = False
LastRow = ActiveSheet.Cells(Rows.Count, "A").End

(xlUp).row
For RowNdx = LastRow To 1 Step -1
with Cells(RowNdx, "A")
if .value = .offset(0,1).value then
Rows(RowNdx).Delete
End If
end with
Next RowNdx
Application.ScreenUpdating = True
End Sub

--
Regards
Frank Kabel
Frankfurt, Germany


Lillian wrote:
I have one big excel spreed sheet, on the ColumnA is

call
staddr, and ColumnB is call mailaddr, if both column as
same address, example "123 main street" then I need to
delete entire row, can everyone show me how to write

with
VB script. I will be really appreciated it.


Lillian

.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default Delete row if columnA and ColumnB are same

Hi
yes, you're correct :-)

--
Regards
Frank Kabel
Frankfurt, Germany


Lillian wrote:
Thanks it work, the offset (0,1) is refer to ColumnB, am
I right? if Column A want to match to ColumnC then I need
to set the offset (0,2), am I correct?


Lillian


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
COUNTIF value columnA columnB Neffa Excel Worksheet Functions 5 August 13th 08 06:57 AM
sum up columnA depending on conditions on columnB and columnC pooposa Excel Discussion (Misc queries) 4 August 5th 06 01:52 AM
Count cells that contain "Y" in columnA IF contains"X" in columnB holliedavis Excel Worksheet Functions 6 July 20th 06 06:12 PM
Adding new numbers as I type without duplicates from Sheet1,ColumnA to Sheet2,ColumnA Master Excel Worksheet Functions 2 July 12th 05 05:03 PM
Delete row if columnA and ColumnB are same Lillian[_5_] Excel Programming 0 June 10th 04 04:26 PM


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