Returning results for an IF in a column - VBA

Mr2017

Well-known Member
Joined
Nov 28, 2016
Messages
644
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Hi

I've got a spreadsheet with a list of data in column H and I'd like to use VBA to return a value in column O that is dependent on the value in column H.

I’d like to search the text using the instr (in string) function then return a value if specific text appears.
Conditions:

If a cell in col. H contains the word FOR and a currency sign eg £, the corresponding cell in col. O returns "Fixed Multibuy"
If a cell in col. H contains the word FOR and a FULL STOP sign ie "." the corresponding cell in col. O returns "Fixed Multibuy"
If a cell in col. H contains the text "3 for 2" the corresponding cell in col. O returns Cheapest Free
If a cell in col. H contains the word "Extra" the corresponding cell in col. O returns "Special Purchase"
otherwise, it returns the words "Special Offer"


Please find below sample data which you can copy and paste into Excel. Please let me know if you have any questions. TIA

Mechanic Conversion
Half Price Special Offer
2 for 3 Fixed Multibuy
2 for 2.50 Fixed Multibuy
3 FOR 2 Cheapest Free

<colgroup><col><col><col><col><col><col><col><col><col><col><col><col><col><col><col></colgroup><tbody>
</tbody>
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
Why VBA ??
You could use this, but I don't think you have given us ALL the criteria


Code:
=IF(OR(H2="FOR",H2="£",H2="FOR."),"Fixed Multibuy",IF(OR(H2="3 for 2",H2="2 for 3",H2="2 for 2.5"),"Cheapest Free",IF(H2="Extra","Special Purchase","Special Offer")))
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,782
Messages
6,121,532
Members
449,037
Latest member
tmmotairi

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