Code Please That Could Save Me Hours

Dazzawm

Well-known Member
Joined
Jan 24, 2011
Messages
3,786
Office Version
  1. 365
Platform
  1. Windows
I need a code that will look at any data that is in column AG and copy it 1 row up and 5 columns to the left (AB) but only if the destination cell has NYA in it. Is this possible please? Thanks
 
whooooops

Code:
Public Sub OogaBoogaSnort()
    With ActiveSheet
        With Intersect(.Columns("AB"), .UsedRange)
            .Value = Evaluate("if(row(),if(" & .Address & "=""NYA"",if(len(" & .Offset(1, 5).Address & ")," & .Offset(1, 5).Address & ",""NYA"")," & .Address & "))")
        End With
    End With
End Sub

Thanks I think you cracked it!
 
Upvote 0

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
Hi Jon. I need this code now to copy across 5 columns as it is now BUT down one row instead of up 1. I thought i could change the offsets to -1 instead of 1 but it comes up with the 400 error again. Thanks.
 
Upvote 0
Do as you were but change the Intersect statement to:

Code:
Intersect(.Columns("AB"), .UsedRange[B][COLOR="Red"].Offset(1)[/COLOR][/B])

The error was because previously the range this referred to began in row #1, and you can't have -1 row from that row position.
 
Upvote 0
Do as you were but change the Intersect statement to:

Code:
Intersect(.Columns("AB"), .UsedRange[B][COLOR=red].Offset(1)[/COLOR][/B])

The error was because previously the range this referred to began in row #1, and you can't have -1 row from that row position.

Thanks I will try tomorrow when back at work.
 
Upvote 0

Forum statistics

Threads
1,224,564
Messages
6,179,544
Members
452,925
Latest member
duyvmex

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