Finding a Title Heading, Cut and Paste

Guzzlr

Well-known Member
Joined
Apr 20, 2009
Messages
955
Office Version
  1. 2016
Platform
  1. Windows
Code:
Set Fnd = Range("6:6").Find("%", , , xlWhole, , , False, , False)
If Not Fnd Is Nothing Then
    Intersect(Range("M7:M5000"), Fnd.EntireColumn).Cut
    Range("Q7").PasteSpecial Paste:=xlPasteValues
End If

I wish to find "%", then cut and paste special values, but as usual, It tells me a variable is not set, which I thought it was.
What did I do wrong?
Thanks for the help
 

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.
I wouldnt know that much of Intersect as i generally stay away from it. Can you try the below?

Code:
Sub test()
Dim fnd As Range
Set fnd = Range("6:6").Find("%", , , xlWhole, , , False, , False)
If Not fnd Is Nothing Then
    Range(Cells(7, fnd.Column), Cells(5000, fnd.Column)).Cut Range("Q7")
    Range("Q7:Q5000").Value = Range("Q7:Q5000").Value
End If
End Sub
 
Upvote 0
This line
Code:
Intersect(Range("M7:M5000"), Fnd.EntireColumn).Cut
should just be
Code:
Fnd.EntireColumn.Cut
 
Upvote 0
Hello,

You could test

Code:
Set Fnd = Range("6:6").Find(What:="%", LookIn:=xlValues, LookAt:=xlPart, MatchCase:=False)

Hope this will help
 
Upvote 0
This line
Code:
Intersect(Range("M7:M5000"), Fnd.EntireColumn).Cut
should just be
Code:
Fnd.EntireColumn.Cut

Think OP only wants from row 7 down though. Obviously better if OP has no data in rows 1-6 or data that can be overwritten.
 
Upvote 0
Good point Barry.
In which case
Code:
Sub chk()
Dim Fnd As Range
Set Fnd = Range("6:6").find("%", , , xlWhole, , , False, , False)
If Not Fnd Is Nothing Then
    Intersect(Range("7:5000"), Fnd.EntireColumn).Copy
    Range("Q7").PasteSpecial xlPasteValues
    Intersect(Range("7:5000"), Fnd.EntireColumn).ClearContents
End If
End Sub
 
Upvote 0
Think OP only wants from row 7 down though. Obviously better if OP has no data in rows 1-6 or data that can be overwritten.

Cut From "T7" down, then special values paste into "Q7", so My code above is wrong in the sense that it sholdld not be M7 but T7.
Thanks
 
Upvote 0
If you know that it's col T, why use Find?
 
Upvote 0

Forum statistics

Threads
1,215,553
Messages
6,125,483
Members
449,233
Latest member
Deardevil

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