Trim / Cut and Paste excess from the next space.

trekker1218

Board Regular
Joined
Feb 15, 2018
Messages
86
Office Version
  1. 2019
Platform
  1. Windows
hello all,
I am currently working on a web site with a description column that cannot exceed 75 char. The data I have exceeds that in certain circumstances.
Is there a VBA or formula you all know that will do this:

Read cell content from right to left.
Stop at the 75th character
then cut all content from the next "SPACE" char. to the right and paste it to the next column on right.
SAMPLE CONTENT in COLUMN AX:
Honeywell VR8345Q4563/U 2-Stage Direct Spark/Electronic Natural/LPG Universal Standard-Opening Combination Gas Control Valve, 3/4 I

If the formula can read from right to the 75th character it would stop at the (a in universal). i need it to read to the next SPACE before the word universal. Then take everything to the right of that space and paste into COLUMN AY.

If working it the other way is easier thats fine too. If the VBA can count to the 75 Char left right. Stop. look for the previous SPACE then cut and paste all content from that space.


Is this possible.

thanks,
 
Last edited:

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
How about
Code:
Sub trekker1218()
   Dim x As Long
   Dim Cl As Range
   
   For Each Cl In Range("A2", Range("A" & Rows.Count).End(xlUp))
      x = InStrRev(Cl, " ", 75, 1)
      If x > 0 Then
         Cl.Offset(, 1).Value = Left(Cl, x - 1)
         Cl.Offset(, 2).Value = Right(Cl, Len(Cl) - x)
      End If
   Next Cl
End Sub
 
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,180
Members
453,021
Latest member
Justyna P

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