moving cells over to the left

daveyc18

Well-known Member
Joined
Feb 11, 2013
Messages
755
Office Version
  1. 365
  2. 2010
hello....there's an issue in my source file where if the account name contains "B BASILIJEVIC," the data is incorrectly shifted one column more to the right.


so, "B BASILIJEVIC" is supposed to be in column U, but is actually in column V. this has shifted anything to the right of "B BASILIJEVIC" one column over as well. e.g., the final column should be "AF", but for the ""B BASILIJEVIC" rows the data it's in column AG.

so what I manually need to do is highlight all the rows containg ""B BASILIJEVIC"m starting from column V to AG, cut then paste to column to U.

essentially, I'm looking for a macro that loops through column V to look for ""B BASILIJEVIC" and then shift the data from column V to AG to column U to AF (ie one column to the left).
 
Last edited:

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
Code:
Sub t()
Dim c As Range
With ActiveSheet
    For Each c In .Range("V2", .Cells(Rows.Count, "V").End(xlUp))
        If c.Value = "B BASILIJEVIC" Then
            c.Resize(, 11).Cut c.Offset(, -1)
        End If
    Next
End With
End Sub
 
Last edited:
Upvote 0
Code:
Option Explicit


Sub DaveyC()
    Dim i As Long, lr As Long
    lr = Range("V" & Rows.Count).End(xlUp).Row
    For i = 1 To lr
        If Range("V" & i) = "B BASILIJEVIC" Then
            Range("V" & i & ":AG" & i).Cut Range("U" & i)
        End If
    Next i
End Sub
 
Upvote 0
This is great. I'd like to add discuss a question to this if this is ok. How do I remove/delete a text contains "SUB" and be able to shift the remain of the data in row one cell over to the left?
A1A2A3A4A5
SUBB1B2B3B4
C1C2C3C4C5
Result:
A1A2A3A4A5
B1B2B3B4B5
 
Upvote 0
This thread is 18 months old, please start a new thread for questions beyond the scope of the original thread.
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,337
Members
452,637
Latest member
Ezio2866

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top