Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 217
  • Last Modified:

How to fix a macro to only cut to one column?

I am having issues with the code below.
I only want it to cut the data from "K" NOT "L".
How do I change this?

.Range(.Cells(Cell.Row, "K"), .Cells(Cell.Row, "L")).Cut .Cells(Cell.Row, "L")
Sub MoveOver1()
    Dim Cell As Range
    Application.ScreenUpdating = False
    With ActiveSheet
'This is where the code checks for which lines have data so just use a column that has data
        For Each Cell In Intersect(.[K:K], .UsedRange)
'This checks for the blank space so change the Column letter to match the cell you are checking
            If .Cells(Cell.Row, "L").Value = "" Then
'This is the move part.  It will cut the range from the first to the second and paste in the column set after the .Cut part
                .Range(.Cells(Cell.Row, "K"), .Cells(Cell.Row, "L")).Cut .Cells(Cell.Row, "L")
            End If
        Next Cell
    End With
    Application.ScreenUpdating = True
End Sub

Open in new window

1 Solution
zorvek (Kevin Jones)ConsultantCommented:

.Range(.Cells(Cell.Row, "K"), .Cells(Cell.Row, "L")).Cut .Cells(Cell.Row, "L")


.Cells(Cell.Row, "K").Cut .Cells(Cell.Row, "L")

eureka15Author Commented:
I was so close...I did not remove the ".range"
Thanks Kevin!

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now