Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Excel Macro Program assistance required

Hi there!

It's been about a billion years since I worked with Excel
macros, I think that part of my brain has atrophied! I
have some inventory data in an Excel spreadsheet, each
item in the inventory is in a row of cells.

There are multiple records for some items. If I sort the
data block by part number first, then "date entered"
second, I get the newest listing for each item first. I
want to delete subsequent listings for the same item.
There are about 18,000 rows in this spreadsheet, so this
seems like a job tailor-made for a tidy little macro.

Here's what I want to do in layman's terms.

1. Select the contiguous block of data
2. Sort the data first on column B (ascending) and second
column L(descending)
3. Place the cursor at the top of column B
4. Read the value of the cell under the cursor into a
register
5. Move the cursor down one cell
6. Does the cell under the cursor have the same
information as the comparison registier?
7. If it does delete the line from the spreadsheet
8. If it does not,read the value of the cell under the
cursor into a register
9. Go back to line 5, repeat

How can I make this happen in a macro? Excel 2002 by the
way.

Thanks for your time!


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 43
Default Excel Macro Program assistance required

If you have done some programming before then the best way
would be to do exactly the steps that you said below,
whist using a record macro. Then go into the code an
change the hard cell references to variables that get
changed in a loop (that does step 5 - step 9 over and over
until it is finished you should probably look up "For
Method" if you forget the loop syntax
-----Original Message-----
Hi there!

It's been about a billion years since I worked with Excel
macros, I think that part of my brain has atrophied! I
have some inventory data in an Excel spreadsheet, each
item in the inventory is in a row of cells.

There are multiple records for some items. If I sort the
data block by part number first, then "date entered"
second, I get the newest listing for each item first. I
want to delete subsequent listings for the same item.
There are about 18,000 rows in this spreadsheet, so this
seems like a job tailor-made for a tidy little macro.

Here's what I want to do in layman's terms.

1. Select the contiguous block of data
2. Sort the data first on column B (ascending) and second
column L(descending)
3. Place the cursor at the top of column B
4. Read the value of the cell under the cursor into a
register
5. Move the cursor down one cell
6. Does the cell under the cursor have the same
information as the comparison registier?
7. If it does delete the line from the spreadsheet
8. If it does not,read the value of the cell under the
cursor into a register
9. Go back to line 5, repeat

How can I make this happen in a macro? Excel 2002 by the
way.

Thanks for your time!


.

  #3   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default Excel Macro Program assistance required

I cannont remember much at all to tell you the truth, my
macro programming experience pre-dates VBA by quite a few
years! How do you declare variables?

-----Original Message-----
If you have done some programming before then the best

way
would be to do exactly the steps that you said below,
whist using a record macro. Then go into the code an
change the hard cell references to variables that get
changed in a loop (that does step 5 - step 9 over and

over
until it is finished you should probably look up "For
Method" if you forget the loop syntax
-----Original Message-----
Hi there!

It's been about a billion years since I worked with

Excel
macros, I think that part of my brain has atrophied! I
have some inventory data in an Excel spreadsheet, each
item in the inventory is in a row of cells.

There are multiple records for some items. If I sort

the
data block by part number first, then "date entered"
second, I get the newest listing for each item first.

I
want to delete subsequent listings for the same item.
There are about 18,000 rows in this spreadsheet, so

this
seems like a job tailor-made for a tidy little macro.

Here's what I want to do in layman's terms.

1. Select the contiguous block of data
2. Sort the data first on column B (ascending) and

second
column L(descending)
3. Place the cursor at the top of column B
4. Read the value of the cell under the cursor into a
register
5. Move the cursor down one cell
6. Does the cell under the cursor have the same
information as the comparison registier?
7. If it does delete the line from the spreadsheet
8. If it does not,read the value of the cell under the
cursor into a register
9. Go back to line 5, repeat

How can I make this happen in a macro? Excel 2002 by

the
way.

Thanks for your time!


.

.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Excel Macro Program assistance required

Here is one way. Paste this into a new VBA module and see
if it works:

Sub Macro1()
Sheets("Sheet1").Select
Range("B1").Select
Selection.Sort Key1:=Range("B2"), Order1:=xlAscending,
Key2:=Range("C2") _
, Order2:=xlDescending, Header:=xlGuess,
OrderCustom:=1, MatchCase:= _
False, Orientation:=xlTopToBottom
Range("B2").Select
Do While ActiveCell.Value < ""
If ActiveCell.Offset(1, 0).Text = ActiveCell.Text Then
ActiveCell.Offset(1, 0).EntireRow.Delete
Else
ActiveCell.Offset(1, 0).Select
End If
Loop
End Sub

Regards
Kevin B

-----Original Message-----
Hi there!

It's been about a billion years since I worked with Excel
macros, I think that part of my brain has atrophied! I
have some inventory data in an Excel spreadsheet, each
item in the inventory is in a row of cells.

There are multiple records for some items. If I sort the
data block by part number first, then "date entered"
second, I get the newest listing for each item first. I
want to delete subsequent listings for the same item.
There are about 18,000 rows in this spreadsheet, so this
seems like a job tailor-made for a tidy little macro.

Here's what I want to do in layman's terms.

1. Select the contiguous block of data
2. Sort the data first on column B (ascending) and second
column L(descending)
3. Place the cursor at the top of column B
4. Read the value of the cell under the cursor into a
register
5. Move the cursor down one cell
6. Does the cell under the cursor have the same
information as the comparison registier?
7. If it does delete the line from the spreadsheet
8. If it does not,read the value of the cell under the
cursor into a register
9. Go back to line 5, repeat

How can I make this happen in a macro? Excel 2002 by the
way.

Thanks for your time!


.

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
Formula assistance required J.Scargill[_2_] Excel Worksheet Functions 3 April 6th 10 10:54 AM
Urgent assistance required for excel Robbo12 Excel Discussion (Misc queries) 2 January 12th 10 03:19 PM
Vlookup Assistance required Megan New Users to Excel 2 November 4th 08 03:46 PM
FORMULA ASSISTANCE REQUIRED Megan Excel Discussion (Misc queries) 9 April 2nd 08 06:35 PM
Assistance required Anthony Excel Discussion (Misc queries) 1 June 2nd 06 11:14 PM


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