• Skip to main content
  • Skip to header right navigation
  • Skip to site footer

My Online Training Hub

Learn Dashboards, Excel, Power BI, Power Query, Power Pivot

  • Courses
  • Pricing
    • Free Courses
    • Power BI Course
    • Excel Power Query Course
    • Power Pivot and DAX Course
    • Excel Dashboard Course
    • Excel PivotTable Course – Quick Start
    • Advanced Excel Formulas Course
    • Excel Expert Advanced Excel Training
    • Excel Tables Course
    • Excel, Word, Outlook
    • Financial Modelling Course
    • Excel PivotTable Course
    • Excel for Customer Service Professionals
    • Excel for Operations Management Course
    • Excel for Decision Making Under Uncertainty Course
    • Excel for Finance Course
    • Excel Analysis ToolPak Course
    • Multi-User Pricing
  • Resources
    • Free Downloads
    • Excel Functions Explained
    • Excel Formulas
    • Excel Add-ins
    • IF Function
      • Excel IF Statement Explained
      • Excel IF AND OR Functions
      • IF Formula Builder
    • Time & Dates in Excel
      • Excel Date & Time
      • Calculating Time in Excel
      • Excel Time Calculation Tricks
      • Excel Date and Time Formatting
    • Excel Keyboard Shortcuts
    • Excel Custom Number Format Guide
    • Pivot Tables Guide
    • VLOOKUP Guide
    • ALT Codes
    • Excel VBA & Macros
    • Excel User Forms
    • VBA String Functions
  • Members
    • Login
    • Password Reset
  • Blog
  • Excel Webinars
  • Excel Forum
    • Register as Forum Member

DELETING OF ROWS WITH VALUES BELOW A CERTAIN RANGE|VBA & Macros|Excel Forum|My Online Training Hub

You are here: Home / DELETING OF ROWS WITH VALUES BELOW A CERTAIN RANGE|VBA & Macros|Excel Forum|My Online Training Hub
Avatar
sp_LogInOut Log In sp_Registration Register
sp_Search Search
Advanced Search|Last Search Results
Search
Forum Scope




Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
sp_Search Search
sp_RankInfo
Lost password?
sp_CrumbsHome HomeExcel ForumVBA & MacrosDELETING OF ROWS WITH VALUES BELOW …
sp_PrintTopic sp_TopicIcon
DELETING OF ROWS WITH VALUES BELOW A CERTAIN RANGE
Avatar
Themba Motha
Member
Members
Level 0
Forum Posts: 8
Member Since:
December 4, 2018
sp_UserOfflineSmall Offline
1
January 12, 2019 - 9:09 pm
sp_Permalink sp_Print

Hi,

Please assist with a macro that can help with deleting entire rows for cells with a value amount of exactly 0 in column "A"

Rgds.

sp_AnswersTopicSeeAnswer See Answer
Avatar
SunnyKow
Puchong, Malaysia

VIP
Members


Trusted Members
Level 8
Forum Posts: 1432
Member Since:
June 25, 2016
sp_UserOfflineSmall Offline
2
January 13, 2019 - 1:58 am
sp_Permalink sp_Print

Hi Themba

Try this

Sub DelRows()
Dim LastRow As Long
Dim i As Long

LastRow = Cells(Rows.Count, "A").End(xlUp).Row

Application.ScreenUpdating = False
For i = LastRow To 1 Step -1
If Cells(i, 1) = 0 Then
Rows(i).Delete Shift:=xlUp
End If
Next
Application.ScreenUpdating = True
End Sub

Sunny

sp_AnswersTopicAnswer
Answers Post
Avatar
David_Ng
Member
Members
Level 0
Forum Posts: 306
Member Since:
December 5, 2016
sp_UserOfflineSmall Offline
3
January 14, 2019 - 10:42 am
sp_Permalink sp_Print

How to modified teh VBA if this cell range contains multiple criteria , say " ABC co" , "Dept", "Allocation Code" , "Currency","Country" 

and to be deleted by macro

Avatar
SunnyKow
Puchong, Malaysia

VIP
Members


Trusted Members
Level 8
Forum Posts: 1432
Member Since:
June 25, 2016
sp_UserOfflineSmall Offline
4
January 14, 2019 - 11:46 am
sp_Permalink sp_Print sp_EditHistory

Are you referring to column A with multiple criteria or multiple column with criteria?

Either way you can use OR to check multiple criteria.

Example:

If Cells(i,1)="X" or Cells(i,2)="Y" OR Cells(i,3)="Z" Then

to delete the row if the any of the cells contains X, Y or Z etc

If all the criteria is in a single column, then you should match cell by cell against a list of criteria instead of using multiple ORs

You can post your file with enough examples for us to understand better what you wanted.

Avatar
David_Ng
Member
Members
Level 0
Forum Posts: 306
Member Since:
December 5, 2016
sp_UserOfflineSmall Offline
5
January 14, 2019 - 1:15 pm
sp_Permalink sp_Print

Tks Sunny , it work perfectly!

Avatar
David_Ng
Member
Members
Level 0
Forum Posts: 306
Member Since:
December 5, 2016
sp_UserOfflineSmall Offline
6
January 14, 2019 - 1:36 pm
sp_Permalink sp_Print

Sub DelRows()
 Dim LastRow As Long
 Dim i As Long

LastRow = Cells(Rows.Count, "A").End(xlUp).Row

Application.ScreenUpdating = False
 For i = LastRow To 1 Step -1
 If Cells(i, 1) = any text { ie  string value] or Cels(i,1) = blank row or  Then
    Rows(i).Delete Shift:=xlUp
 End If
 Next
 Application.ScreenUpdating = True
 End Sub

 

How to re-write the macro if Column A data contact any string value or blank row,  then delete , leaving only date value in the column A data

Avatar
SunnyKow
Puchong, Malaysia

VIP
Members


Trusted Members
Level 8
Forum Posts: 1432
Member Since:
June 25, 2016
sp_UserOfflineSmall Offline
7
January 14, 2019 - 4:11 pm
sp_Permalink sp_Print

Try

If Not IsDate(Cells(i,1)) Then

Avatar
David_Ng
Member
Members
Level 0
Forum Posts: 306
Member Since:
December 5, 2016
sp_UserOfflineSmall Offline
8
January 14, 2019 - 4:54 pm
sp_Permalink sp_Print

Tks will try

Avatar
David_Ng
Member
Members
Level 0
Forum Posts: 306
Member Since:
December 5, 2016
sp_UserOfflineSmall Offline
9
January 14, 2019 - 7:02 pm
sp_Permalink sp_Print

I tried and confirm the Syntex work. Thanks again Sunny..

If Not IsDate(Cells(i,1)) Then

Avatar
SunnyKow
Puchong, Malaysia

VIP
Members


Trusted Members
Level 8
Forum Posts: 1432
Member Since:
June 25, 2016
sp_UserOfflineSmall Offline
10
January 15, 2019 - 1:08 am
sp_Permalink sp_Print

OK No problem.

sp_Feed
Go to top
Forum Timezone: Australia/Brisbane
Most Users Ever Online: 245
Currently Online: Mynda Treacy, Suzanne Halfacre, Dieneba NDIAYE, Dario Serrati, Jay Soysa, Marco Marques
Guest(s) 10
Currently Browsing this Page:
1 Guest(s)
Top Posters:
SunnyKow: 1432
Anders Sehlstedt: 870
Purfleet: 412
Frans Visser: 346
David_Ng: 306
lea cohen: 219
A.Maurizio: 202
Jessica Stewart: 202
Aye Mu: 201
jaryszek: 183
Newest Members:
dectator mang
Francis Drouillard
Orlando Inocente
Jovitha Clemence
Maloxat Axmatovna
Ricardo Freitas
Marko Meglic
Kelly smith
Alan Rushton
Zack Nilsson
Forum Stats:
Groups: 3
Forums: 24
Topics: 6200
Posts: 27181

 

Member Stats:
Guest Posters: 49
Members: 31858
Moderators: 3
Admins: 4
Administrators: Mynda Treacy, Philip Treacy, Catalin Bombea, FT
Moderators: MOTH Support, Velouria, Riny van Eekelen
© Simple:Press —sp_Information

Sidebar

Blog Categories

  • Excel
  • Excel Charts
  • Excel Dashboard
  • Excel Formulas
  • Excel PivotTables
  • Excel Shortcuts
  • Excel VBA
  • General Tips
  • Online Training
  • Outlook
  • Power Apps
  • Power Automate
  • Power BI
  • Power Pivot
  • Power Query
microsoft mvp logo
trustpilot excellent rating
Secured by Sucuri Badge
MyOnlineTrainingHub on YouTube Mynda Treacy on Linked In Mynda Treacy on Instagram Mynda Treacy on Twitter Mynda Treacy on Pinterest MyOnlineTrainingHub on Facebook
 

Company

  • About My Online Training Hub
  • Disclosure Statement
  • Frequently Asked Questions
  • Guarantee
  • Privacy Policy
  • Terms & Conditions
  • Testimonials
  • Become an Affiliate

Support

  • Contact
  • Forum
  • Helpdesk - For Technical Issues

Copyright © 2023 · My Online Training Hub · All Rights Reserved. Microsoft and the Microsoft Office logo are trademarks or registered trademarks of Microsoft Corporation in the United States and/or other countries. Product names, logos, brands, and other trademarks featured or referred to within this website are the property of their respective trademark holders.