Can anyone help on adding to a macro

ghrek

Active Member
Joined
Jul 29, 2005
Messages
426
Hi

I have this macro as shown below but trying to add to it.

Is there anyway that I can move the data as per macro but also move the data in the column next to it too if there are specific words.

If the data has the word "PAYMENT VALUE" or "FARE" I need the data from the cell that contains that word moved over and also the cell next to it. Say A14 has the word PAYMENT VALUE I need that moved to column BD but then B14 moved to Column BE too.

VBA Code:
Option Explicit

Sub Macro399
    Dim c As Range, rng As Range
    Dim lr As Long, r As Long
    lr = Range("A" & Rows.Count).End(xlUp).Row
    Set rng = Range("A1:BB" & lr)
    Application.ScreenUpdating = False
    For Each c In rng
        If UCase(c) = "SALE NUMBER (SDCI+)" Then
            r = c.Row
            c.Cut Range("BD" & r)
        End If
    Next c
    Application.ScreenUpdating = True
    Application.CutCopyMode = False

End Sub
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
Maybe (untested)...
Rich (BB code):
Sub Macro399()
    Dim c As Range, rng As Range
    Dim lr As Long, r As Long
    lr = Range("A" & Rows.Count).End(xlUp).Row
    
    Set rng = Range("A1:BB" & lr)
    Application.ScreenUpdating = False
    
    For Each c In rng
        If UCase(c) = "SALE NUMBER (SDCI+)" Then
            r = c.Row
            c.Cut Range("BD" & r)
        End If
        If UCase(c) = "PAYMENT VALUE" Or UCase(c) = "FARE" Then
            r = c.Row
            c.Resize(, 2).Cut Range("BD" & r)
        End If
    Next c
    
    Application.ScreenUpdating = True
    Application.CutCopyMode = False

End Sub
 
Upvote 0

Forum statistics

Threads
1,214,983
Messages
6,122,592
Members
449,089
Latest member
Motoracer88

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