VBA Code vbNewLine Issue

Tashat

Board Regular
Joined
Jan 12, 2005
Messages
137
Office Version
  1. 365
Platform
  1. Windows
Hi All - I am not able to write my own VBA code without support and I have found some code on another site which works almost perfectly, but I need some advice on a tweak, but I don't know the syntax. Am I allowed to post the code here and credit the person who wrote it, but just ask for some support on changing it slightly?

It is code which allows a data validation drop-down box to accept multiple entries and puts each entry on a new line within the cell (example below without code). My issue is that the last entry in each cell automatically has a new line (vbNewLine) appended to it, making it "different" from an entry which appears at the top of the list, or mid-list when I produce a power query based on the data. I've included an example below (without the code) to illustrate my point. For example "Strawberries" in cells A2 and A5 are the "same", but in cell A4 it is "Strawberries" with a line break after, so therefore is "viewed" differently in my PowerQuery. Am I allowed to post the code in here to ask for help with changing it so the last entry in each cell doesn't have a line-break (vbNewLine) associated with it?


Book1
AB
1ListShop
2Strawberries Apples OrangesSainsburys
3Apples PearsMorrisons
4Blueberries Oranges StrawberriesTesco
5Oranges Apples Strawberries BlueberriesAsda
Sheet1
 
Glad we could help & thanks for the feedback.
 
Upvote 0

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.

Forum statistics

Threads
1,224,830
Messages
6,181,225
Members
453,025
Latest member
Hannah_Pham93

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