Long Expression in SetValue Macro

DMurray3

New Member
Joined
Dec 23, 2010
Messages
26
Hi all,

On a Form, I am trying to write a macro ta will "calculate" the full product name based on the product's attributes (and abbreviations I have in the corresponding attribute tables.

The formula is:
=IIf([txtFamilyAb]="No Definido";"Producto No Definido";IIf([txtFamilyAb]="PROD";"PR" & " " & IIf([txtSubLine]="No Definido";"";[txtSubLineAb]) & " " & IIf([txtType]="No Definido";"";[txtTypeAb]) & " " & IIf(Len([Brand])<=1 Or [Brand]="NA";"";Left([Brand];15)) & " " & IIf(Len([Model])<=1 Or [Model]="NA";"";Left([Model];10)) & " " & IIf(Len([Dimen])<=1 Or [Dimen]="NA";"";Left([Dimen];15)) & " " & IIf(Len([cboMaterial])<=1 Or [cboMaterial]="NA";"";Left([cboMaterial];15)) & " " & IIf([Warp]="NA";"";IIf([Warp]="Blanco";"U-B";"U-N")) & " " & IIf([Weft]="NA";"";[Weft] & " COL") & " " & IIf([Stiffness]="NA" Or [Stiffness]="Ninguno 0%";"";"APRES") & " " & Switch([Present]="Rollo";"ROLLOS";[Present]="CorteRecto";"C-RECT";[Present]="DobladoExtremos";"CD-EXTR";[Present]="DobladoMedio";"CD-MED";[Present]="Trapecio";"CD-TRAP";[Present]="NA";"");"SRV" & " " & IIf([txtSubLine]="No Definido";"";[txtSubLineAb])))

Unfortunately, the Expression builder does not allow the length of the formula.

Can any one provide guidance and a sample of breaking up this long formula and how to set it in the Macro ? Although I prefer to do this with a macro tied to a button on the form, Ias as a second alternative, could you provide a sample VBA to assign to a "*******" event.

Many thanks for your help.

Kind regards,
dmurray3
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"

Forum statistics

Threads
1,221,816
Messages
6,162,149
Members
451,746
Latest member
samwalrus

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