Insert a Missing Word to Find

Guzzlr

Well-known Member
Joined
Apr 20, 2009
Messages
982
Office Version
  1. 2021
Platform
  1. Windows
Hello All...
I have another issue.
Code:
Set Fnd = Range("4:4").Find("Bureau", , , xlWhole, , , False, , False)
        If Not Fnd Is Nothing Then
            Intersect(Range("4:5000"), Fnd.EntireColumn).Cut
            Range("M4").Insert shift:=xlToRight
        End If

What if the word "Bureau" is not in the Range to Find? How can I have excell automatically insert the word "Bureau", then continue with the Cut/Insert?
Thanks for the help
excel 2013
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
Where would you insert it?
 
Upvote 0
Rather than inserting it in what I presume is a blank column, why not just do
Code:
Set Fnd = Range("4:4").Find("Bureau", , , xlWhole, , , False, , False)
If Not Fnd Is Nothing Then
    Intersect(Range("4:5000"), Fnd.EntireColumn).Cut
    Range("M4").Insert shift:=xlToRight
 Else
    Range("M4").EntireColumn.Insert
    Range("M4").Value = "Bureau"
End If
 
Upvote 0
Rather than inserting it in what I presume is a blank column, why not just do
Code:
Set Fnd = Range("4:4").Find("Bureau", , , xlWhole, , , False, , False)
If Not Fnd Is Nothing Then
    Intersect(Range("4:5000"), Fnd.EntireColumn).Cut
    Range("M4").Insert shift:=xlToRight
 Else
    Range("M4").EntireColumn.Insert
    Range("M4").Value = "Bureau"
End If

This is smart...I'll try it and report back. Thank you
 
Upvote 0
Code:
Set Fnd = Range("4:4").Find("Bureau", , , xlWhole, , , False, , False)
If Not Fnd Is Nothing Then
    Intersect(Range("4:5000"), Fnd.EntireColumn).Cut
    Range("M4").Insert shift:=xlToRight
 Else
    Range("M4").EntireColumn.Insert
    Range("M4").Value = "Bureau"
End If

This looks like it is working, I can use this logic on all the FND's in the code!
Thank you!
 
Upvote 0
Glad to help & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,284
Members
452,630
Latest member
OdubiYouth

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