Consulting

Results 1 to 4 of 4

Thread: Amend code - Important - Please

  1. #1
    VBAX Contributor
    Joined
    Aug 2007
    Posts
    165
    Location

    Amend code - Important - Please

    hi i have the following vba code.

    I need the code to stop inserting row in the ActualData worksheet and just delete the item i have told it to delete from the Eligible Portfolios sheet.

    I also need to keep row 8 columns c to ay fixed "header information" - all other rows below if deleted - with the macro function to move up one, keeping the data compact.

    Also need to auto function filter removed......

    here is the code:

    Public Sub DeletionCriteria()
    Dim mpCriteria As String
    Do
    mpCriteria = InputBox("PLEASE DELETE ANY OLD PORTFOLIO DATA - ")
    If mpCriteria <> "" Then
    Call DeleteData(Worksheets("EligiblePortfolios").Columns("B:B"), mpCriteria, True)
    Call DeleteData(Worksheets("ActualData").Columns("E:E"), mpCriteria)
    End If
    Loop While mpCriteria <> ""
    End Sub

    Private Sub DeleteData(pzData As Range, pzCriteria, Optional blnHeader As Boolean = False)

    If pzData.Parent.AutoFilterMode Then
    pzData.AutoFilter
    End If

    With Intersect(pzData, pzData.Parent.UsedRange)
    If Not blnHeader Then
    .Parent.Rows(1).Insert
    .Cells(1, 1).Value = ""
    .AutoFilter Field:=1, Criteria1:=pzCriteria
    If Not Intersect(.Parent.Range("14:65536"), .SpecialCells(xlCellTypeVisible)) Is Nothing Then
    Intersect(.Parent.Range("14:65536"), .SpecialCells(xlCellTypeVisible)).EntireRow.Delete
    End If
    .AutoFilter
    Else
    .AutoFilter Field:=1, Criteria1:=pzCriteria
    .Offset(14, 0).Resize(.Rows.Count - 14).SpecialCells(xlCellTypeVisible).EntireRow.Delete
    .AutoFilter
    End If
    End With

    End Sub

    thanks.

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Quote Originally Posted by keilah
    I need the code to stop inserting row in the ActualData worksheet and just delete the item i have told it to delete from the Eligible Portfolios sheet.
    Insert which row?

    Quote Originally Posted by keilah
    I also need to keep row 8 columns c to ay fixed "header information" - all other rows below if deleted - with the macro function to move up one, keeping the data compact.
    What does that mean?

    Quote Originally Posted by keilah
    Also need to auto function filter removed......
    And what does that mean?

    Can't you post the workbook, guessing your data is tough.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    VBAX Contributor
    Joined
    Aug 2007
    Posts
    165
    Location
    Hi Xld

    point 1. Each time the user tells the macro to delete a entry from the Eligible Portfolios worksheet, the same entry is also deleted from the ActualData worksheet. this works fine.
    However, when you go to the actualdata worksheet to check that the entry has been removed. The original data the was placed in

    row 8 columns C:AY - moves to row 9 same columns range.

    Point2. Row 8 column C:AY has information that tells the user what information in each column relates to. So delete all rows below row 8....keeping row 8 information displayed all the time.

    Point3. Ignore this point silly point raised by me...

    thanks for the feedback....await your reply.

    once again thanks

  4. #4
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    As far as I can see, it starts at row 14 so I don't see what row 8 has to do with it.

    As I said, without a workbook it is very difficult to envisage the data, so I for one withdraw until I see one.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

Posting Permissions

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