New to Macros need help

theColonel

New Member
Joined
May 31, 2012
Messages
9
I just started working with Macros today. What I'm trying to do with it is filter through information of a report and format it automatically for me. Which would spare me from doing it by hand which can take awhile.

Sub Macro4()
'
' Macro4 Macro
'
'
ActiveWindow.SmallScroll Down:=78
Range("B102:K102").Select
Selection.Cut
Range("A102").Select
ActiveSheet.Paste
End Sub

This is what I have so far, I think I understand how to change the ranges accordingly to make it work. But how would I have it conditionally go through and move a row of cells over/cut and paste if column 2 had the word "Sub" in it? Do I need to learn how to loop it? Thanks in advance for any help.
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Maybe something like this?
Code:
Sub MoveSub()

    Dim myLastRow As Long
    Dim i As Long
    
    Application.ScreenUpdating = False
    
'   Find last row in 2nd column
    myLastRow = Cells(Rows.Count, "B").End(xlUp).Row
    
'   Loop through all cells in column B and move to column C if "Sub" is in cell
    For i = 1 To myLastRow
        If InStr(UCase(Cells(i, "B")), "SUB") > 0 Then
            Cells(i, "C") = Cells(i, "B")
            Cells(i, "B").ClearContents
        End If
    Next i
    
    Application.ScreenUpdating = True
    
End Sub
 
Upvote 0

Forum statistics

Threads
1,203,514
Messages
6,055,840
Members
444,828
Latest member
StaffordStag

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