Search for Data in Column "C" and move to Column "B"

mrjojo

New Member
Joined
Sep 23, 2011
Messages
8
How would I go about using the Macros in Excel 2007 to Search for any Data in Column "C" and "cut-and-paste" it into Column "B" in the same row? It will need to search the entire column except for anything in Row 1.

Any help would be greatly appreciated.
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
If you have Excel 2003 macro then it will still work!
 
Upvote 0
From your first post, I got impression that you were having 2007- version code.
Code 1:
Code:
Public Sub CopyPaste()
Application.ScreenUpdating = False
Dim lLastRow As Long
lLastRow = Range("C" & Rows.Count).End(xlUp).Row
For i = 2 To lLastRow
    If Range("C" & i).Value <> "" Then Range("C" & i).Cut Range("B" & i)
Next i
Application.ScreenUpdating = True
End Sub
Another way:
Code:
Public Sub CopyPaste1()
Application.ScreenUpdating = False
Dim r As Range
For Each r In Range("C2:C" & Range("C" & Rows.Count).End(xlUp).Row)
    If r.Value <> "" Then r.Cut r.Offset(, -1)
Next r
Application.ScreenUpdating = True
End Sub
 
Upvote 0
Another variant

Code:
Sub CopyPaste1Biz()
    Application.ScreenUpdating = False
    Dim r As Range
    For Each r In Range("C2:C" & Range("C" & Rows.Count).End(xlUp).Row)
        If r.Value <> "" Then
            r.Offset(, -1) = r
            r.ClearContents
        End If
    Next r
    Application.ScreenUpdating = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,508
Messages
6,179,188
Members
452,893
Latest member
denay

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