Execute a "Text To Columns" IF a specific text is found

andymalan

Board Regular
Joined
Feb 22, 2017
Messages
128
Office Version
  1. 365
  2. 2007
Platform
  1. Windows
Dear Friendly Learned People, I want to search Column B for the word "shelf". When it is found, do "Text To Columns" on the cell 1 row down and 1 column to the right from the cell where the word was found. e.g. if "shelf" is found in B23, then execute "Text To Columns" on cell C24. BUT ONLY IF B24 is empty. If B24 is not empty, continue search. approximately 1200 rows.

I am sure that this can be done, but by persons more clever than I.

I will be so grateful and I thank you in advance
Kind regards
Andy

>>
'search for "shelf"
Application.DisplayAlerts = False
Set rng = Range("B2:B1500") ' (RANGE TO SEARCH)
specificText = "Shelf" ' (text to search for)
For Each cell In rng.Cells
If UCase(cell.Value) Like "*" & UCase(specificText) & "*" Then
cell.Offset(1, -1).Select
Selection.Delete
'

Selection.TextToColumns Destination:=cell.Offset(0, 1).Select, DataType:=xlFixedWidth, _
FieldInfo:=Array(Array(0, 1), Array(5, 1), Array(7, 1), Array(11, 1), Array(18, 1), _
Array(20, 1), Array(23, 1), Array(33, 1), Array(35, 1), Array(38, 1)), _
TrailingMinusNumbers:=True

End If

Next

1673970305952.png
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.

Forum statistics

Threads
1,214,957
Messages
6,122,466
Members
449,086
Latest member
kwindels

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