VBA How to get county out of the Address block and put it under County's column?

vbanewbie68

Board Regular
Joined
Oct 16, 2021
Messages
171
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
Hi Sir/Madam

Please find attached.

I want to tell macro to get off "West Sussex" under Donor Address line 1's column ,the last end, and then paste it into the Donor County's column? and Also how to remove commas as well Please? I have a list of hundreds like that.

Thank you in advance :)

Best Regards

V
 

Attachments

  • Address block.png
    Address block.png
    121.2 KB · Views: 15
Would you be able to help me to build the new codes to support that?
To do what with an example like the blue one above?

Take the wrong county and wrong column D like row 15 below?.
or
Take whatever is after the last comma but highlight it if not in the provided list like row 16

vbanewbie68.xlsm
DEF
1576 Lane, NorthumberlendEssex
1676 Essex LaneNorthumberlend
County


Also please clarify exactly what should appear in each column if there is
- no correct county name (eg "15 Wood Lane, Essx")
- more than one correct county name (eg 23 Essex-Kent Link Road, West Sussex")
- a correct county name but is just part of another word (eg 44 Kenthurst Road, Essx")
 
Upvote 0

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
To do what with an example like the blue one above?

Take the wrong county and wrong column D like row 15 below?.
or
Take whatever is after the last comma but highlight it if not in the provided list like row 16

Also please clarify exactly what should appear in each column if there is
- no correct county name (eg "15 Wood Lane, Essx")
- more than one correct county name (eg 23 Essex-Kent Link Road, West Sussex")
- a correct county name but is just part of another word (eg 44 Kenthurst Road, Essx")
 
Upvote 0
Aberdeenshire
Alderney
Anglesey
Angus
Argyll
Argyllshire
Avon
Ayrshire
Banffshire
Bath and North East Somerset
Bedfordshire
Berkshire
Berwickshire
Brecknockshire
Bridgend County
Bromley
Buckinghamshire
Buteshire
Caerphilly
Caithness
Cambridgeshire
Cardiganshire
Carmarthenshire
Ceredigion
Channel Islands
Cheshire
Clackmannanshire
Cleveland
Clwyd
Conwy
Cornwall
County Antrim
County Armagh
County Carlow
County Cavan
County Clare
County Cork
County Donegal
County Down
County Dublin
County Dun Laoghaire-Rathdown
County Durham
County Fermanagh
County Galway
County Kerry
County Kildare
County Kilkenny
County Laois
County Leitrim
County Limerick
County Londonderry
County Longford
County Louth
County Mayo
County Meath
County Monaghan
County Offaly
County Roscommon
County Sligo
County Tipperary
County Tyrone
County Waterford
County Westmeath
County Wexford
County Wicklow
Cromartyshire
Cumberland
Cumbria
Denbighshire
Derbyshire
Devon
Dorset
Dumfriesshire
Dunbartonshire
Durham
Dyfed
East Lothian
East Sussex
East Yorkshire
Essex
Fife
Flintshire
Glamorgan
Gloucestershire
Grampian
Greater Manchester
Guernsey
Gwent
Gwynedd
Hampshire
Herefordshire
Hertfordshire
Huntingdonshire
Inverclyde
Inverness-shire
Isle of Arran
Isle of Barra
Isle of Benbecula
Isle of Bute
Isle of Coll
Isle of Cumbrae
Isle of Harris
Isle of Islay
Isle of Lewis
Isle of Man
Isle of Mull
Isle of Scilly
Isle of Skye
Isle of South Uist
Isle of Tiree
Isle of Wight
Isles of Scilly
Jersey
Kent
Kincardineshire
Kinross-shire
Kirkcudbrightshire
Lanarkshire
Lancashire
Leicestershire
Lincolnshire
Merseyside
Mid Glamorgan
Middlesex
Midlothian
Monmouthshire
Montgomeryshire
Morayshire
Nairnshire
Norfolk
North Humberside
North Lincolnshire
North Somerset
North Yorkshire
Northamptonshire
Northumberland
Nottinghamshire
Orkney
Oxfordshire
Peeblesshire
Pembrokeshire
Perthshire
Powys
Radnorshire
Renfrewshire
Rhondda Cynon Taff
Ross-Shire
Roxburghshire
Rutland
Selkirkshire
Shetland
Shropshire
Somerset
South Ayrshire
South Glamorgan
South Gloucestershire
South Humberside
South Lanarkshire
South Yorkshire
Staffordshire
Stirlingshire
Strathclyde
Suffolk
Surrey
Sutherland
Torfaen
Tyne & Wear
Tyne and Wear
Vale of Glamorgan
Warwickshire
West Glamorgan
West Lothian
West Midlands
West Sussex
West Yorkshire
Wigtownshire
Wiltshire
Worcestershire
Yorkshire
Ynys Mon

Above is the list of counties and if match is found in the address block then extract it and move it to the County's column.

Hope it helps?

Regards

V
 
Upvote 0
Above is the list of counties and if match is found in the address block then extract it and move it to the County's column.
I guess that answers
To do what with an example like the blue one above?

Take the wrong county and wrong column D like row 15 below?.
and
if there is
- no correct county name (eg "15 Wood Lane, Essx")

but it does not clarify ..
clarify exactly what should appear in each column if there is

- more than one correct county name (eg 23 Essex-Kent Link Road, West Sussex")
- a correct county name but is just part of another word (eg 44 Kenthurst Road, Essx")

Also, the long list provided would ideally need to be in a worksheet column somewhere, like in column L of the image in post #6. Would that be feasible for you?
 
Upvote 0
I guess that answers

and


but it does not clarify ..


Also, the long list provided would ideally need to be in a worksheet column somewhere, like in column L of the image in post #6. Would that be feasible for you?

Would be great for a long list in a worksheet instead please?
V
 
Upvote 0
It would be good to highlight in red if the match is found and then msg box either yes or no. If yes then move it to the county’s column. Could use a list of counties onto another workbook? Would that be another option?

Best regards

V
 
Upvote 0
There are still two example texts that I asked for clarification about to which you have not responded.
 
Upvote 0
Apologies for the confusion: Hope below is what you are looking for?

1. Also please clarify exactly what should appear in each column if there is
- no correct county name (eg "15 Wood Lane, Essx")
This should be in red to flag up a double check for us to decide and then correct the spelling manually if needed.

2. more than one correct county name (eg 23 Essex-Kent Link Road, West Sussex")
This is something we need a red flag up in the column F for us to decide and correct it manually?

3. a correct county name but is just part of another word (eg 44 Kenthurst Road, Essx")
That also need in the column F to flag up for us to decide. Then correct it manually if needed.

Best regards
 
Upvote 0
Thanks, but I'm afraid I am still not entirely clear on exactly what you want and where.

Possibly the following might help at least partially. For the sample data below and using the full list of counties from post #13, could you manually prepare the expected results in columns D and F exactly as you would want them to appear, including any 'flags', and post those results?

vbanewbie68.xlsm
DEF
1Donor Address Line 1Donor County
2754, Ellenbri Way,West Sussex
3123, Wood Lane,Northumberland
45, Smith St, Essex
526 Jordan Rd, Kent
676 Essex Lane, Northumberlend
715 Wood Lane, Essx
823 Essex-Kent Link Road, West Sussex
944 Kenthurst Road, Essx
101 Hill Road, Mod Glamorgan
County
 
Upvote 0
Thanks, but I'm afraid I am still not entirely clear on exactly what you want and where.

Possibly the following might help at least partially. For the sample data below and using the full list of counties from post #13, could you manually prepare the expected results in columns D and F exactly as you would want them to appear, including any 'flags', and post those results?

vbanewbie68.xlsm
DEF
1Donor Address Line 1Donor County
2754, Ellenbri Way,West Sussex
3123, Wood Lane,Northumberland
45, Smith St, Essex
526 Jordan Rd, Kent
676 Essex Lane, Northumberlend
715 Wood Lane, Essx
823 Essex-Kent Link Road, West Sussex
944 Kenthurst Road, Essx
101 Hill Road, Mod Glamorgan
County

Thanks for the message. Would it be possible to create a msgbox to tell us when there is a potential alert to link to the county. Then we decide Yes or no we can click the button? If yes, then we can extract it from the address block to the county column?

Regards

V
 
Upvote 0

Forum statistics

Threads
1,215,832
Messages
6,127,149
Members
449,365
Latest member
AlienSx

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