×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Autofilter and Delete(partial row deletion)

Autofilter and Delete(partial row deletion)

Autofilter and Delete(partial row deletion)

(OP)
Below is the code I posted earlier to filter and delete rows that meet certain criteria.

CODE --> VBScript

const xlUp = -4162
lastRow = ws1.UsedRange.Rows.Count
lastColumn = ws1.UsedRange.Columns.Count

Set rngDataBlock = ws1.Range(ws1.Cells(1,1),ws1.Cells(lastRow,lastColumn))

rngDataBlock.AutoFilter 4,"a",,,False

If ws1.Cells(1,4).Value = "a" Then
	ws1.AutoFilter.Range.Delete xlUp
Else
	ws1.AutoFilter.Range.Offset(1).Delete xlUp
End If

ws1.AutoFilterMode = False 


I would now only like to delete and shift cells up the filtered rows only from Column D to F. Can I get help with code for this task?

RE: Autofilter and Delete(partial row deletion)

Hi,

It just makes no sense in a table to shift some of the columns of data from one row to another, leaving other rows without data that has been shifted elsewhere.

Nonsense!

Skip,

glassesJust traded in my OLD subtlety...
for a NUance!tongue

"The most incomprehensible thing about the universe is that it is comprehensible" A. Einstein

RE: Autofilter and Delete(partial row deletion)

First, apply autofilter only to proper area. Assuming that it is isolated range:

Set rngDataBlock = ws1.Cells(4,3).CurrentRegion

combo

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login


Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close