Delete Every Other Row or Column in Excel (using Formula or VBA)

Today we are going to explore various ways to delete every other row or delete every other column in Excel. VBA macro code is included to help you on your way if that is the path you choose.

Additionally, we will also cover how to delete every third/fourth/fifth row or column in Excel.

To delete alternate rows, you can use a helper column and use a formula that helps you identify alternate rows. This could be done by using the ISEVEN function that checks each row number and returns TRUE if the row is even and false if it isn’t.

Once you have this, you can easily filter the rows with FALSE in the helper columns and delete these.

In case you want to delete every third row, you need to use the MOD function to identify every third row. Once you have it, you can easily filter and delete every third row or every fourth row.

I also cover a method to use a simple VBA code to delete alternate rows in Excel.

Below is that VBA CODE TO DELETE ALTERNATE ROWS:

Sub Delete_Every_Other_Row()
Dim Rng As Range
Set Rng = Application.InputBox("Select the Range (Excluding headers)", "Range Selection", Type:=8)
For i = Rng.Rows.Count To 1 Step -2
If i Mod 2 = 0 Then
Rng.Rows(i).Delete
End If
Next i
End Sub

When it comes to deleting alternate columns, you cannot filter these. You can instead sort and bring all those columns together that you want to delete.

I cover a simple method that uses the MOD function to identify alternate columns and then sort these from left-to-right to bring these together. Once you have these in one place, you can select and delete these.

And there is also a VBA code that you can use to delete alternate columns.

Below is the VBA CODE TO DELETE ALTERNATE COLUMNS

Sub Delete_Every_Other_Column()
Dim Rng As Range
Set Rng = Application.InputBox("Select the Range (Excluding headers)", "Range Selection", Type:=8)
For i = Rng.Columns.Count To 1 Step -2
If i Mod 2 = 0 Then
Rng.Columns(i).Delete
End If
Next i
End Sub

Subscribe to this YouTube channel to get updates on Excel Tips and Excel Tutorials videos – https://www.youtube.com/c/trumpexcel

You can find a lot of useful Excel resources on the following site: https://trumpexcel.com/

#Excel #ExcelTips #ExcelTutorial

View on YouTube

Power Query Filter Rows by NOT Contains Criteria – Single Formula Solution

Learn how to filter a table based on NOT Contains Criteria. Download an example workbook here.

Easy step by step instructions below.  See a single formula solution using the functions Splitter.SplitByAnyDelimiter, List.Count and Table.SelectRows. Amazing formula solution from Power Query Poet, Bill Szysz.

Please watch the video if you’d like for a guided walkthrough and also another method that can be useful for multiple tables.  

Criteria Table

  1. Create a new, separate table with the list of terms you will want to exclude. Name the table “NoCriteria”.
  2. Add the excluded item (NoCriteria) table to Power Query – click within table, under Data menu, choose From Table/Range, which is in the Get and Transform data section.
  3. In the Power Query window, select the Transform menu and click convert to list.
  4. Under the File menu, choose Close and Load To, then choose Connection Only.

Building the Filtering via Power Query

  1. Add or create the list/table that will ultimately be filtered.
  2. Click any cell within the table that will be filtered. Add the excluded item table to Power Query (click within table, under Data menu, choose From Table/Range, which is in the Get and Transform data section).
  3. In the Power Query window, click the Add Column menu, and select Custom Column.
  4. In the window that opens, type this:

    = Table.SelectRows(#”Changed Type”, each List.Count (Splitter.SplitTextByAnyDelimiter(NoCriteria)([PRODUCT_NAME]))=1)

  5. Change [PRODUCT_NAME] in that text to your own column in the table that you will be filtering on if it is different.
  6. Select the statement you have typed in and copy it (you will need to paste this formula in a following step).
  7. Click OK. You will see that the formula you typed was changed by the program and a column was added.
  8. To change the formula back, click the menu bar, highlight the entire text and then replace by pasting in the formula you copied. Hit enter.
  9. The extra column should be removed and the table should be filtered on you criteria from the NoCriteria table.
  10. Click the File menu, choose Close and Load To, then choose where you would like the newly filtered table loaded to.

Any time changes are made to the exclusion list, you will need to refresh the filtered table. Simply right click any cell within the filtered table, and select Refresh.

 

Bonus – Filtered table with the excluded items only (not shown in video)

You can additionally create a filtered table that only includes the terms in your NoCriteria table!  

  1. To do this, go into Power Query.  Right click on your filtered table and click Duplicate.
  2. In that new table, you will very slightly change the existing formula in your Power Query to not equal one (see orange text):

    = Table.SelectRows(#”Changed Type”, each List.Count (Splitter.SplitTextByAnyDelimiter(NoCriteria)([PRODUCT_NAME]))<>1)

  3. Hit enter.  The table should now only filter on the items in your exclusion list, instead of including them.
  4. Click the File menu, choose Close and Load To, then choose where you would like the newly filtered table loaded to.

View on YouTube

Create A Gantt Chart In Power BI With A Matrix Visual

Managing projects effectively requires clear visuals that communicate timelines and task progress at a glance. While Power BI offers many visuals, building a Gantt chart using the built-in Matrix visual is a powerful technique for showing detailed project timelines without needing custom visuals. This blog post walks through the key concepts and steps for creating a Power BI matrix Gantt chart, perfect for project managers and data analysts alike.

What is a Matrix Gantt Chart in Power BI?

A Gantt chart visually represents project schedules by showing tasks as bars mapped over calendar dates. Unlike using custom Gantt chart visuals, you can cleverly use Power BI’s matrix visual combined with DAX formulas and conditional formatting to mimic a Gantt chart. This approach is advantageous because it leverages native visuals without extra installation, is highly customizable, and integrates seamlessly with your existing data models and filters.

Why Use a Matrix Gantt Chart?

  • Native Power BI Visual: No need for third-party downloads or licensing.
  • Dynamic and Interactive: Integrates with slicers and filters for dynamic timeline updates.
  • Detailed Task View: Offers drill-down capabilities across project hierarchies.
  • Full Control Over Design: Customize colors and styles through conditional formatting rules.

Step-by-Step Guide to Creating a Power BI Matrix Gantt Chart

  1. Prepare Your Data Model
  2. Your dataset should include at least these columns:
    • Project or Task Name
    • Start Date
    • End Date or Duration(Optional)
    • Task Status or Category
    • You also need a Date table in your data model to serve as a timeline backbone.
  3. Establish Relationship sConnect your Date table to your Project table using the Start Date (and possibly End Date) fields to enable time intelligence across visuals.
  4. Create a Matrix Visual
    • Place Project Name (and subcategories if needed) in the Rows.
    • Place Date from the Date table in the Columns.
  5. Create a DAX Measure to Highlight Task DurationWrite a measure that returns 1 if a given date falls within the task start and end dates and 0 otherwise. This will be the basis for your Gantt bars.Example simplified logic: TaskActive = IF( SELECTEDVALUE('Date'[Date]) >= MIN('Projects'[StartDate]) && SELECTEDVALUE('Date'[Date]) <= MAX('Projects'[EndDate]), 1, 0 )
  6. Apply Conditional Formatting Use conditional formatting on the Matrix’s Values field. Format the background color to:
    • Show a distinct color (e.g., gold or blue) when the TaskActive measure equals 1. Show a lighter or neutral color when 0.
    This creates the visual bars of the Gantt chart within the matrix cells.
  7. Enhance Your Visual
    • Turn off subtotals for clarity.
    • Use slicers to filter projects or timelines dynamically.
    • Add tooltips with task details.
    • Customize colors by task status or category using additional measures and formatting rules.

Benefits of Using a Matrix Gantt Chart in Power BI

  • Cost-effective: No licensing or external visuals needed.
  • Integrated experience: Aligns with your Power BI reports and dashboards perfectly.
  • Scalable: Works well from small projects to complex multi-phase portfolios.
  • Customizable: You control colors, interactivity, and granularity.

By leveraging Power BI’s matrix visual combined with smart DAX measures and conditional formatting, you can build a robust, customizable Gantt chart tailored to your project management reporting needs. Start experimenting with your project data today and unlock richer timeline insights right inside Power BI!

Other Options/Resources

For those interested in alternative approaches, there are also custom Gantt chart visuals available in Power BI Marketplace, but the matrix method provides unmatched flexibility and control for many project reporting scenarios.

Delete Rows Based on a Cell Value (or Condition) in Excel [With and Without VBA]

Managing data efficiently in Excel often means removing unwanted rows that meet certain criteria—such as rows with specific text, dates, numbers, or even partial matches. Whether you’re cleaning up a small spreadsheet or preparing a large dataset for analysis, understanding how to delete rows based on cell values will help you keep your data tidy and relevant. This guide explores multiple techniques to remove rows in Excel according to specific cell values, making your data management tasks faster and more accurate regardless of your proficiency with Excel features or VBA automation.

This tutorial explains several methods to remove rows from an Excel worksheet based on the value in a specific cell or according to set conditions.

Here are four different approaches you can use to delete rows depending on their cell values:

  1. Using Filters:
    Apply a filter to your data, select the criteria you want to remove (for example, rows where “Status” is “Inactive”), and delete all the filtered rows at once.
  2. Sorting Data:
    Sort your data by the column you want to filter (e.g., sort by “Department” so all “Sales” records are grouped together) and then delete all the matching rows in one go.
  3. Finding Cells with Specific Values:
    Use Excel’s “Find” feature to locate cells with a value like “Expired”, select those rows, and delete them all together.
  4. VBA Automation:
    Automate row deletion by using a VBA macro that filters and deletes based on your criteria (e.g., remove all rows where “Order Status” is “Cancelled”).

Tip:
Choose the method that best fits your dataset’s structure and your workflow. Remember, deleting a row removes everything in that row—including all data to the left and right. If you only want to clear certain cells but keep the row and other information, consider using the filter and dummy column trick, or manually clearing cell contents instead of deleting the row.

Wildcard Matching Example:
With Find and Replace, you can use wildcards for powerful matching. For instance, to find every region ending with “East” (such as “North-East” or “South-East”), type “*-East” (the asterisk stands for any sequence of characters).

Example VBA Codes

Delete All Rows Where “Status” is “Inactive”:

textSub DeleteRowsWhereInactive()
    ActiveCell.AutoFilter Field:=3, Criteria1:="Inactive" 'Assumes the Status column is column 3
    ActiveSheet.AutoFilter.Range.Offset(1, 0).Rows.SpecialCells(xlCellTypeVisible).Delete
End Sub

Prompt User before Deleting Rows Where “Order Status” is “Cancelled” Without Deleting the Entire Row:

textSub DeleteCancelledStatusCells()
    Dim MsgboxAns As Integer
    ActiveCell.AutoFilter Field:=4, Criteria1:="Cancelled" 'Assumes Order Status is column 4
    MsgboxAns = MsgBox("Are you sure you want to delete these cells?", vbYesNo + vbQuestion)
    If MsgboxAns = vbYes Then
        ActiveSheet.AutoFilter.Range.Offset(1, 0).Rows.SpecialCells(xlCellTypeVisible).Delete (xlShiftUp)
    End If
End Sub

Delete Rows in an Excel Table Where “Department” is “Support”:

textSub DeleteRowsinTableForDepartment()
    Dim Tbl As ListObject
    Set Tbl = ActiveSheet.ListObjects(1)
    ActiveCell.AutoFilter Field:=2, Criteria1:="Support" 'Assumes Department is column 2
    Tbl.DataBodyRange.SpecialCells(xlCellTypeVisible).Delete
End Sub

**#Excel #ExcelTips #A #ExcelTutorial

Let me know if you need more tailored code or examples for your data!

Cross Selling Matrix Deep Dive – Power BI & DAX Tutorial

In this tutorial we cover how to create a cross selling matrix.

This requires a full understanding of the concept of ‘context’ and much more.

Some advanced DAX formulas are covered in detail, especially table functions.

Plenty of great techniques to learn about during this one.

Enjoy!

Sam

***** Learning Power BI? *****

FREE COURSE – Ultimate Beginners Guide To Power BI – http://bit.ly/2SGof6C

FREE COURSE – Ultimate Beginners Guide To DAX – http://bit.ly/2AyEb3P

FREE – Power BI Resources – http://bit.ly/2C2aBn3

FREE – 60 Page DAX Reference Guide Download – http://bit.ly/2AyEc7T

Learn more about Enterprise DNA – http://bit.ly/2RacRD3

Enterprise DNA Membership – http://bit.ly/2AAqa5u

View on YouTube

Formula.Firewall Error in Power Query & Power BI: Rebuild This Data Combination Solved (MSPTDA 9.5)

Learn how to deal with Power Query Error: Formula.Firewall: Query references other queries or steps, so it may not directly access a data source. Please rebuild this data combination. Two solutions are presented in this video.
Download Files: Excel Start: https://ift.tt/2L7OwpO
Zipped Folder: https://ift.tt/2PShOvY
Download Excel FINISHED Files: https://ift.tt/2MsL7Hs
Download pdf Notes about Power Query: https://ift.tt/2wkNW2K
Assigned Homework – these are problems for you to practice your new M Code skills:
Download Excel File with Homework: https://ift.tt/2MmtxFf
Example of Finished Homework: https://ift.tt/2L7OxtS

Chris Webb’s blog about this topic: https://ift.tt/2NATkG3
Ken Puls blog about this topic: https://ift.tt/2PShRb8

Comprehensive Microsoft Power Tools for Data Analysis Class, BI 348, taught by Mike Girvin, Excel MVP and Highline College Professor.

View on YouTube

excel vlookup tutorial for beginners to advanced with examples

VLOOKUP Function Beginner to Advanced With Examples: How To Use Excel VLOOKUP Function

What is VLOOKUP and why it matters

The Excel VLOOKUP function searches for a value in the first column of a table and returns a value from a specified column in the same row, which makes it perfect for pricing lookups, HR rosters, invoices, commissions, and taxonomy maps across large datasets without manual searching. VLOOKUP’s syntax is =VLOOKUP(lookup_value, table_array, col_index_num, [range_lookup]) where the lookup value must be in the leftmost column of the table array, the return column is selected by index, and the final argument controls exact vs. approximate matching.

Exact match VLOOKUP for clean lookups

For unique identifiers like IDs, SKUs, or emails, use exact match with FALSE (or 0) to return only precise matches and avoid unexpected results, which is the most common production pattern in business workbooks. A typical formula is =VLOOKUP(E2, $A$2:$C$11, 2, FALSE), with the table range locked using absolute references so it copies reliably down a column while the lookup reference remains relative for each row.

Approximate match VLOOKUP for bands and tiers

Approximate match is ideal for tax brackets, commission tiers, shipping rates, or grade scales, where the first column is sorted ascending and Excel returns the closest value less than or equal to the lookup value when an exact match doesn’t exist. When the last argument is TRUE or omitted, VLOOKUP returns the next smaller match in a sorted table, which is essential for continuous ranges like “income-to-tax-rate” or “sales-to-commission” bands.

Preventing errors with IFERROR and best practices

Production-grade sheets guard against #N/A and related issues by wrapping VLOOKUP in IFERROR to show a clean message or blank when a value is missing, and by using data validation lists to eliminate typos at the source of the lookup value. Following best practices like locking the table with $A$2:$D$100, ensuring the lookup key sits in the leftmost column, and documenting whether a formula is exact or approximate match will make your workbooks resilient and easier to maintain.

Cross-sheet and cross-workbook references

VLOOKUP works seamlessly across sheets and files by including sheet names (Sheet2!$A$2:$D$100) or external workbook paths in the table_array, which enables central lookup catalogs, shared master data, and distributed models while preserving consistent references via absolute ranges. When linking to closed workbooks, Excel embeds the file path in the reference, so keeping related files together and stable is important for long-term reliability.

Dynamic col_index_num with MATCH

Hard-coding the column index makes models brittle; pairing VLOOKUP with MATCH on the header row creates a dynamic column index that automatically adapts when columns are moved or new fields are inserted. For example, =VLOOKUP($E2, $A$2:$Z$100, MATCH($G$1, $A$1:$Z$1, 0), FALSE) uses the header text in G1 to return the correct column even if the schema changes, which is a best-in-class pattern for durable reports.

Horizontal and vertical record retrieval

Full-record retrieval can be automated horizontally with COLUMNS and vertically with ROWS to pull multiple adjacent fields from a single VLOOKUP key without manual indexing, which is useful for summary views, profile cards, and line items. Using expandable ranges with COLUMNS(B8:B8)+1 for horizontal sequences or ROWS(B22:B22)+1 for vertical sequences produces 1, 2, 3 indices as formulas copy, keeping the sheet tidy and dynamic.

Multi-criteria VLOOKUP strategies

VLOOKUP returns the first match and can’t natively filter duplicates, so multi-criteria lookups are solved by creating a helper “join key” column (e.g., =A2&”|”&B2) and using the same join in the lookup value, which creates a unique, leftmost key VLOOKUP can read. If schema changes are not allowed, an advanced alternative uses CHOOSE inside VLOOKUP to construct a two-column virtual table in-memory, enabling multi-field keys without altering the source range, which is powerful for protected or external datasets..

Partial text lookups and text-number mismatches

Real data often requires extracting part of a code to perform a lookup, where LEFT/RIGHT/MID combined with SEARCH finds variable-length segments like prefixes before a dash, or three-character mids after a delimiter, creating consistent keys to match against the table. When numbers are stored as text (or vice versa), coercing with +0 or VALUE ensures reliable matching, and using TRIM removes hidden spaces that can otherwise cause #N/A even when values look identical on screen.

VLOOKUP limitations and when to use alternatives

VLOOKUP only looks to the right, is case-insensitive, and returns only the first match, which can be restrictive in analytics and deduping workflows, especially in wide tables where column order changes over time. More flexible patterns include INDEX/MATCH for left-lookups or returning nth matches, and modern functions like XLOOKUP that support bidirectional lookup, exact/approximate logic, default values, and built-in error handling with a cleaner syntax for both beginners and power users.

VLOOKUP examples you can copy

Basic exact match (best for IDs, SKUs)
=VLOOKUP(E2, $A$2:$D$100, 3, FALSE) returns the value from the 3rd column where A matches E2 in a locked table range for safe copying.

Approximate match for tiers (sorted ascending)
=VLOOKUP(E2, $A$2:$C$20, 2, TRUE) returns the banded rate or amount when E2 falls between thresholds in the first column, which must be ascending.

Dynamic column with MATCH
=VLOOKUP($E2, $A$2:$Z$100, MATCH($G$1, $A$1:$Z$1, 0), FALSE) adapts to column moves by resolving the column index from header text in G1.

Multi-criteria with helper join
=VLOOKUP($H2&”|”&$I2, $A$2:$E$100, 5, FALSE) matches two inputs by concatenating them to a unique leftmost key (e.g., Name|State).

CHOOSE-based two-key (no schema change)
=VLOOKUP($H2&”|”&$I2, CHOOSE({1,2}, $A$2:$A$100&”|”&$B$2:$B$100, $E$2:$E$100), 2, FALSE) builds a virtual two-column table for a composite key without adding a helper column.

Partial text before a dash
=VLOOKUP(LEFT(E2, SEARCH(“-“, E2)-1), $A$2:$C$100, 2, FALSE) extracts the left segment as the key when source IDs contain a prefix-delimiter pattern.

Coercing text numbers
=VLOOKUP(VALUE(MID(E2, SEARCH(“-“, E2)+1, 3)), $A$2:$C$100, 2, FALSE) converts a three-digit middle segment to a number for consistent matching.

Trim hidden spaces reliably
=VLOOKUP(TRIM(E2), $A$2:$D$100, 3, FALSE) cleans errant whitespace in the lookup value; if spaces are in the table’s first column, apply TRIM to that column or reconstruct a trimmed array pattern where appropriate.

Pro tips for learning

Beginners should start with exact matches on clean tables and practice absolute references, then add IFERROR to handle missing keys gracefully, and use data validation to reduce typos in lookup cells during entry, which mirrors enterprise data hygiene. Intermediate and advanced users benefit from MATCH-driven column selection, helper columns for multi-key joins, CHOOSE-based virtual tables when schemas are locked, and partial text extraction patterns that mirror real-world IDs from CRMs, ERPs, and finance systems

keywords: excel vlookup tutorial for beginners to advanced with examples, vlookup help, vlookup.

Other resources to help you:

  1. https://www.ablebits.com/office-addins-blog/excel-vlookup-tutorial/
  2. https://support.microsoft.com/en-us/office/vlookup-function-0bbc8083-26fe-4963-8ab8-93a18ad188a1
  3. https://www.excel-easy.com/examples/vlookup.html
  4. https://www.goskills.com/Excel/Resources/VLOOKUP-exact-match-approximate-match
  5. https://www.w3schools.com/excel/excel_vlookup.php
  6. https://www.youtube.com/watch?v=-hJxIMBbmZY
  7. https://www.extendoffice.com/documents/excel/6393-excel-vlookup-function.html
  8. https://www.youtube.com/watch?v=DZEPA9UhLBw
  9. https://www.semrush.com/blog/how-to-choose-long-tail-keywords/
  10. https://www.youtube.com/watch?v=xIynD1gFOLo
  11. https://www.ablebits.com/office-addins-blog/vlookup-formula-examples/
  12. https://www.youtube.com/watch?v=v5l82vjuMpY
  13. https://www.youtube.com/playlist?list=PL856071E833250503
  14. https://www.youtube.com/watch?v=w0KQ5ByxELo
  15. https://www.reddit.com/r/excel/comments/16szzbc/teach_me_vlookup_in_excel/
  16. https://www.youtube.com/watch?v=zqFE6uIJ65s
  17. https://www.youtube.com/watch?v=ck9MR95MtZg
  18. https://www.youtube.com/watch?v=ZGKpXh426Ko
  19. https://www.youtube.com/user/ExcelIsFun
  20. https://www.youtube.com/watch?v=-1BDpwCxyug
  21. https://www.youtube.com/watch?v=d3BYVQ6xIE4