Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9009485
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T02:12:32+00:00 2026-06-16T02:12:32+00:00

I have a CSV file in which I have lots of empty columns. I

  • 0

I have a CSV file in which I have lots of empty columns. I have Ms Excel 2010 but, I don’t know how to use Macros or sort functions.

I already did a Google search and followed the steps. They didn’t help me. Can someone guide me through step by step process for deleting empty columns?

Edited:

Sorry, I didn’t know how this site works. It was hard for me to go through my web search history to find out the proper links as I have been searching all day.

But I have some links from my history that were helpful for similar people like me (but not me :()

http://www.addictivetips.com/windows-tips/how-to-delete-remove-blank-rows-columns-in-excel-2010-spreadsheet/
http://www.mrexcel.com/archive/VBA/11225.html

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T02:12:33+00:00Added an answer on June 16, 2026 at 2:12 am

    Here’s a macro that will go through all columns, from the last one with any data in it to the first, and delete any columns that have nothing in them:

    Sub DeleteEmptyColumns()
    
        Dim lastColumn As Integer
        Dim lastRow As Integer
        Dim i As Integer
        Dim r As Range
    
        Set r = ActiveSheet.Cells.Find("*", SearchOrder:=xlByColumns, LookIn:=xlValues, SearchDirection:=xlPrevious)
    
        If Not r Is Nothing Then
    
            lastColumn = r.Column
    
            For i = lastColumn To 1 Step -1
    
                Set r = ActiveSheet.Columns(i).Find("*", SearchOrder:=xlByRows, LookIn:=xlValues, SearchDirection:=xlPrevious)
    
                If r Is Nothing Then
                    ActiveSheet.Columns(i).Delete
                Else
                    If r.Row = 1 Then
                        ActiveSheet.Columns(i).Delete
                    End If
                End If
    
            Next i
    
        End If
    
    End Sub
    

    In addition: it won’t crash if there’s nothing at all in the sheet, and you don’t have to limit yourself to a certain number of columns, it’ll check all of them automatically.

    EDIT: Modified to skip the first row and ignore any headers.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Little Background: I have csv file which has lots of rows and each row
I have a csv file which may have empty or blank rows. I want
I have a CSV file which contains an ID and several other columns. I
I have a csv file which includes 3 columns, 100+rows. The variables in all
I have a csv file which has 3 columns. I am trying to search
I have a csv file which I want to convert to xml but the
I currently have a CSV file which, when opened in Excel, has a total
I have a csv file which has two columns, a numeric ID ( IDVAR
I have simple csv file which is tab delimited which i have to use
I have a CSV file which has the following format: id,case1,case2,case3 Here is a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.