Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Macro help needed

I have a couple of worksheets that have customer number, name, address,
city, state & zip code in a couple of the worksheets.

The first list is about 3000 rows long, the second one is about 100 rows
long.

What I need to do is to write a macro to take the list in the second
sheet, find it if it exists in the first sheet, and delete the record in
the first sheet.

Can anyone help, or provide a source of some macro tutorials to do this
type of thing?

I would know how to do this inside SQL, but don't know how to do it in
Excel VBA.

Thanks,

BC
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Macro help needed

Here's a go at it...

Private Sub CommandButton1_Click()

Dim DL As Worksheet
Dim ML As Worksheet

Dim DropRow As Integer
Dim MasterRow As Integer

Set DL = Sheets("DropList")
Set ML = Sheets("MasterList")

DropRow = 2 ' droppable names start in the 2nd row

While Not IsEmpty(DL.Cells(DropRow, 1))
MasterRow = 2 ' master list starts on 2nd row

While Not IsEmpty(ML.Cells(MasterRow, 1))

If ML.Cells(MasterRow, 1) = DL.Cells(DropRow, 1) And _
ML.Cells(MasterRow, 2) = DL.Cells(DropRow, 2) And _
ML.Cells(MasterRow, 3) = DL.Cells(DropRow, 3) And _
ML.Cells(MasterRow, 4) = DL.Cells(DropRow, 4) And _
ML.Cells(MasterRow, 5) = DL.Cells(DropRow, 5) And _
ML.Cells(MasterRow, 6) = DL.Cells(DropRow, 6) Then

ML.Rows(MasterRow).Delete
Else
MasterRow = MasterRow + 1
End If

Wend

DropRow = DropRow + 1

Wend

End Sub

You'll want to customize the two sheet names and make sure my row/
column offsets match where your data resides. This macro requires
that all 6 fields match up before it will delete the customer from the
master list. This may or may not be what you want. You can trim down
my large IF .. AND .. AND .. to suit your needs.

HTH

Brian Herbert Withun

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
Macro needed Bryan[_4_] New Users to Excel 3 February 16th 08 07:39 PM
Macro Help Needed - Excel 2007 - Print Macro with Auto Sort Gavin Excel Worksheet Functions 0 May 17th 07 01:20 PM
Macro needed to set macro security in Excel to minimum Carl Excel Programming 3 March 18th 06 03:36 PM
Macro needed to Paste Values and prevent Macro operation thunderfoot Excel Discussion (Misc queries) 1 June 11th 05 12:44 AM
Macro needed to Paste Values and prevent Macro operation thunderfoot Excel Discussion (Misc queries) 0 June 10th 05 03:38 PM


All times are GMT +1. The time now is 01:50 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"