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 7769067
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T16:04:26+00:00 2026-06-01T16:04:26+00:00

I’ve been working on simplifying a script, I wanted to create a script that

  • 0

I’ve been working on simplifying a script, I wanted to create a script that would copy within a range of columns over to the furthest left unoccupied column. Then delete the original column.

I’ve tweaked this script I found to do mostly what I wanted, it copies everything over, but doesn’t delete.

I also need it to make it so that it can choose which row in said column range to look at for reference.

Could someone take a look at the script and help finish what I’ve started? I’ve been learning Excel VBA slowly, and my work has caused me to jump ahead in multiple directions before I have been ready, so I know that the copy and delete options should be simple, but because of the my line of work, I haven’t had the time to learn everything correctly, so sorry if this is a simple answer, but I need to keep this script as lean as possible, and this is what I’ve come up with so far with what I know and scoured the internet for code and help.

Option Explicit

Sub MoveColumns()

    Dim cel As Range

    With ActiveSheet
        For Each cel In Intersect(.UsedRange, .[B:N]).SpecialCells(xlCellTypeBlanks).Cells
            cel = cel.Offset(0, 1)
        Next
    End With
End Sub

Thanks in advance.

  • 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-01T16:04:27+00:00Added an answer on June 1, 2026 at 4:04 pm

    don’t mind the data under the main, I have a script that will get rid of it, so when this script runs it will run with nothing under it. In the case I want to move Copy G:G to F:F, then Delete G:G, move H:H to G:G, delete H:H, and continue till all the columns are side by side, with no space inbetween and no duplicates anywhere else.

    What you want is complicated way of moving things. The easiest way is to delete the blank column. The rest of the columns will automatically move to the left 🙂 I am assuming that there is no data after row 194.

    Try this

    Option Explicit
    
    Sub MoveColumns()
        Dim ws As Worksheet
        Dim lastCol As Long, i As Long
        Dim DelRange As Range
    
        Set ws = Sheets("BackOrder")
    
        With ws
            lastCol = .Cells.Find(What:="*", _
            After:=.Range("A1"), _
            Lookat:=xlPart, _
            LookIn:=xlFormulas, _
            SearchOrder:=xlByColumns, _
            SearchDirection:=xlPrevious, _
            MatchCase:=False).Column
    
            For i = 1 To lastCol
                If Application.WorksheetFunction.CountA(.Columns(i)) = 0 Then
                    If DelRange Is Nothing Then
                        Set DelRange = .Columns(i)
                    Else
                        Set DelRange = Union(DelRange, .Columns(i))
                    End If
                End If
            Next
    
            If Not DelRange Is Nothing Then DelRange.Delete
        End With
    End Sub
    

    HTH

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

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm trying to create an if statement in PHP that prevents a single post
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I would like to count the length of a string with PHP. The string
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace

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.