Partial String Match using VBA to autopopulate an address

darcus

New Member
Joined
Jun 30, 2014
Messages
29
Hi

I'm looking to increase the functionality in an invoicing program I'm working on.

I would like to have auto recognition of delivery address using VBA in excel.

VBA seems to be a necessity as the cell that displays the delivery address needs to be autopopulated and then allow modification.

CELLS
E11 = Folio number for a customer.
E15 = Delivery method.
Cells B19:B31 - these cells contain order numbers and represent a line on the invoice.
B39 = note section.

SHEETS
'Invoice' = this sheet is used for entry of information.
'Del' = this sheet is used to story delivery address information.

The 'Del' sheet looks like this:
ABCD
1FOLIOLOCATIONMATCHADDRESS
2W14SUFFIX91 Letsby Avenue, Coventry, CV1 1AA
3W14SUFFIX64 Some Place, Leicester, LE1 4AA
4W14SUFFIX459 Another Toon, Leeds, L2 4AA
5T02PREFIX5252 Worthing Add, Truro, TR1 1AA
6T02PREFIX47494 Units, Biz, B2 3AA
...

<tbody>
</tbody>
Hi

I'm looking to increase the functionality in an invoicing program I'm working on.

I would like to have auto recognition of delivery address using VBA in excel.

VBA seems to be a necessity as the cell that displays the delivery address needs to be autopopulated and then allow modification.

CELLS
E11 = Folio number for a customer.
E15 = Delivery method.
Cells B19:B31 - these cells contain order numbers and represent a line on the invoice.
B39 = note section.

SHEETS
'Invoice' = this sheet is used for entry of information.
'Del' = this sheet is used to story delivery address information.

The 'Del' sheet looks like this:
ABCD
1FOLIOLOCATIONMATCHADDRESS
2W14SUFFIX91 Letsby Avenue, Coventry, CV1 1AA
3W14SUFFIX64 Some Place, Leicester, LE1 4AA
4W14SUFFIX459 Another Toon, Leeds, L2 4AA
5T02PREFIX5252 Worthing Add, Truro, TR1 1AA
6T02PREFIX47494 Units, Biz, B2 3AA
...

<tbody>
</tbody>

The checking has to happen in the following order:
1. Folio number is selected
2. Delivery method is selected.
There are two options when the 'Del' sheet needs to be used to lookup an address:
UPS
Linkline
If any another option is selected here (like 'Collected') then we don't need to run the code.
3. Once we have to lookup an address we need the following to happen:
a) Match the folio on the 'Del' sheet to look up possible addresses.
b) See if the part of the order number (in cells B19 up to B31) that decides the address is a suffix or a prefix.
c) If there are multiple order numbers in B19:B31 and the resulting delivery addresses are different – then we need to show a popup stating ‘CONFLICTING DELIVERY ADDRESSES – Please verify’. With just an option to bypass the popup.
Typically the first order number has the same prefix/suffix as the ones below it.
d) Then match the address from column D and dump this into cell B39 in the following format:
Sent via [delivery_method] to [delivery_address]

delivery_method = 'Invoice'=E15
delivery_address = 'Del'=D

I am sure this is doable - just not clear on how I am to implement this - especially considering that B39 should be populated as and when I enter in the order number for each line on the invoice...so a bit like a formula.

I don't know how to select between two formulae (that look for a prefix or a suffix based on 'Del' column B.). I was going to use a formula to perform the lookup and then have a button that copies the lookup into that cell so that I can edit it if I choose... But that looks like a silly way of doing it.

Thanks.
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.

Forum statistics

Threads
1,215,039
Messages
6,122,802
Members
449,095
Latest member
m_smith_solihull

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