Insert a Missing Word to Find

Guzzlr

Well-known Member
Joined
Apr 20, 2009
Messages
956
Office Version
  1. 2016
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

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
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,215,575
Messages
6,125,619
Members
449,238
Latest member
wcbyers

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