Character Limit As Conditions

DataBlake

Well-known Member
Joined
Jan 26, 2015
Messages
781
Office Version
  1. 2016
Platform
  1. Windows
Hello All,
I'm looking for efficiency so a formula or VBA will work for this.
I'm trying to find the best way to create a title that is as close to 80 characters as possible
So the title is broken down like this

Quantity - Color1 - Brand1 - Size1 - Style1 - Pattern1 - Size2 - Brand2 - ImportantText - Manufacturer
so as an example:

5 Black Poof 12x8 Snagl 4x123 44" POP XT Broom & Fork Package Googley Goggle 1900

Code:
="5 "&Poof!D2&" "&[/FONT][/FONT][FONT=arial]Poof!B2&" "&Poof!G2&" "&Poof!C2&" "&Poof!J2&" "&Poof!I2&" "&POP!B2&" "&POP!E2&" Broom & Fork Package "&TitleHelper!B2[/FONT]

any information regarding "1" (color, brand, size, etc) is found in sheet "Poof"
any information regarding "2" (color, brand, size, etc) is found in sheet "POP"

Hopefully that paints a good picture as this is usually the amount of info that gets closest to 80 characters
but sometimes it goes over and sometimes i could fit more info.
So here are the general rules that i would like it to follow

For Pattern1 there are two patterns in "Poof" [Columns J & K]
If K is not blank pick the shorter pattern and use that

If the title is too long:
if the title is over 80 characters replace "TitleHelperB2" with "TitleHelperC2"
if the title is still over 80 characters get rid of the "&" in "Broom & Fork Package"
if the title is still over 80 characters get rid of the quantity at the beginning "5 "
if the title is still over 80 characters get rid of Brand2 "POP!B2"
if the title is still over 80 characters display an error message

and if the title is too short:

if the title is less than 65 add Style2 "POP!D2" in between Brand2 and ImportantText ["POP!B2" & " Broom & Fork Package"]
if the title is still less than 70 add the 2nd pattern from "Poof" after Pattern1 [Poof!J2"&" "&Poof!K2] as long as Poof!K2 is not blank

*Note if adding these puts the title over 80 characters then don't add them*
I will try to create a sensitive info version of the workbook
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
okay so here is the workbook in screenshots as well as a download link

https://drive.google.com/file/d/1QO51HQQo9QiYZxEcQ9yueEls8YyF0h2s/view?usp=sharing

P9Otkb4.png


Qs3zw5e.png


DNvEic4.png


ocyC45m.png
 
Last edited:
Upvote 0
okay so this is what i've got on my own with nested if statements

Code:
=IF(SUM(LEN("5 "&Poof!D2&" "&Poof!B2&" "&Poof!G2&" "&Poof!C2&" "&Poof!J2&" "&Poof!I2&" "&POP!B2&" "&POP!E2&" Wheel & Tire Package "&TitleHelper!B2))<80,"5 "&Poof!D2&" "&Poof!B2&" "&Poof!G2&" "&Poof!C2&" "&Poof!J2&" "&Poof!I2&" "&POP!B2&" "&POP!E2&" Wheel & Tire Package "&TitleHelper!B2,IF(SUM(LEN("5 "&Poof!D2&" "&Poof!B2&" "&Poof!G2&" "&Poof!C2&" "&Poof!J2&" "&Poof!I2&" "&POP!B2&" "&POP!E2&" Wheel & Tire Package "&TitleHelper!C2))<80,"5 "&Poof!D2&" "&Poof!B2&" "&Poof!G2&" "&Poof!C2&" "&Poof!J2&" "&Poof!I2&" "&POP!B2&" "&POP!E2&" Wheel & Tire Package "&TitleHelper!C2,IF(SUM(LEN("5 "&Poof!D2&" "&Poof!B2&" "&Poof!G2&" "&Poof!C2&" "&Poof!J2&" "&Poof!I2&" "&POP!B2&" "&POP!E2&" Wheel Tire Package "&TitleHelper!C2))<80,"5 "&Poof!D2&" "&Poof!B2&" "&Poof!G2&" "&Poof!C2&" "&Poof!J2&" "&Poof!I2&" "&POP!B2&" "&POP!E2&" Wheel Tire Package "&TitleHelper!C2,IF(SUM(LEN(Poof!D2&" "&Poof!B2&" "&Poof!G2&" "&Poof!C2&" "&Poof!J2&" "&Poof!I2&" "&POP!B2&" "&POP!E2&" Wheel Tire Package "&TitleHelper!C2))<80,Poof!D2&" "&Poof!B2&" "&Poof!G2&" "&Poof!C2&" "&Poof!J2&" "&Poof!I2&" "&POP!B2&" "&POP!E2&" Wheel Tire Package "&TitleHelper!C2,IF(SUM(LEN(Poof!D2&" "&Poof!B2&" "&Poof!G2&" "&Poof!C2&" "&Poof!J2&" "&Poof!I2&" "&POP!E2&" Wheel Tire Package "&TitleHelper!C2))<80,Poof!D2&" "&Poof!B2&" "&Poof!G2&" "&Poof!C2&" "&Poof!J2&" "&Poof!I2&" "&POP!E2&" Wheel Tire Package "&TitleHelper!C2,"err")))))

this encapsulates and works for all of the conditions where the title it too long and gives me "err" if its still over 80
now this isn't optimal, but it'll work for now.
it does NOT include the conditions where the title is too short.
 
Upvote 0

Forum statistics

Threads
1,216,138
Messages
6,129,099
Members
449,486
Latest member
malcolmlyle

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