Two evaluate if functions in VBA

Status
Not open for further replies.

RockandGrohl

Well-known Member
Joined
Aug 1, 2018
Messages
794
Office Version
  1. 365
Platform
  1. Windows
Hello, trying to wrap my head around Evaluate, one of these formulas was helpfully given by the legendary Fluff:

VBA Code:
  With Range("K2:K" & LastrowPPD)
      .Value = Evaluate("if({1},"" ""&" & .Address & "&"","")")
   End With

What this doing is appending the start of each entry in range K with a space, and the end with a comma.

Unfortunately, this does not like strings longer than 255 characters and I have more than a few cells where the string length is quite long.

Also, can someone explain what the {1} means in the if statement? Thanks.



Secondly I'd like to expand this "with range" to also append "Making own way" on to cells in the range, where the equivalent row in column AD has "Making own way" written.

As an example:

KADResult:
1Pickups
2 Altrincham, Bedford, Chepstow, Making own way Altrincham, Bedford, Chepstow, Making own way,
3 Birmingham, Solihull, Redditch Birmingham, Solihull, Redditch
4 Milton Keynes, Newhaven, Oxford, Making own way Milton Keynes, Newhaven, Oxford, Making own way
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
Duplicate to: Faster way to append string in range?

In future, please do not post the same question multiple times. Per Forum Rules (#12), posts of a duplicate nature will be locked or deleted.

In relation to your question here, I have closed this thread so please continue in the linked thread.
 
Upvote 0
Status
Not open for further replies.

Forum statistics

Threads
1,216,788
Messages
6,132,701
Members
449,753
Latest member
swastikExcel

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