+ Reply to Thread
Results 1 to 3 of 3

Deleting unwanted data by macro or...

Hybrid View

  1. #1
    Registered User
    Join Date
    03-08-2006
    Posts
    11

    Deleting unwanted data by macro or...

    I posted this question in the "Excel Programming" thread, but this seems to be too simple for that thread.

    I have a list that looks like this:

    A...........B...........C...........D
    Item......Size1......Size2.....Size3 (Header)
    Item1.......$2........$3.........$4
    Item2.......$1........$2.........$3
    Item3.......$4........$5.........$6

    "Item2" only comes in the first two sizes (Size1, and Size2), so I want to add a column where I would specify the max size for "Item2", and a macro would delete the Size3 price for Item2. (I would do this to all items in my list)

    Something like this:

    A...........B...........C...........D...........E
    Item......Size1......Size2.....Size3....MaxSize (Header)
    Item1.......$2........$3.........$4...........3
    Item2.......$1........$2.......................2
    Item3.......$4........$5.........$6...........3

    Thank You,
    Leibtek

  2. #2
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967

    Response

    Try the following user defined function which you need to place on the tab corresponding to your sheet of data (e.g. sheet1) in the VBA editor.

    Private Sub Worksheet_Change(ByVal Target As Range)
    MaxColumn = 5
    If Target.Column = MaxColumn And Target.Columns.Count = 1 And Target.Rows.Count = 1 And IsNumeric(Target) Then
    For N = MaxColumn - 1 To Int(Target.Value) + 2 Step -1
    Cells(Target.Row, N).ClearContents
    Next N
    End If
    End Sub

  3. #3
    Registered User
    Join Date
    03-08-2006
    Posts
    11
    Thanks, - Worked Great.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1