• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

how to use power query split part of number

Oscarr

Member
hi

anyone know how to use power query split part of number? pls refer attachment

Thanks
 

Attachments

  • example.xlsx
    8.4 KB · Views: 5
  1. Load from table
  2. define as text data type
  3. split by number of characters (PQ to my knowledge does not see colour), like Hui suggested via formula.upload_2018-1-26_8-1-26.png
  4. transforms to this...
upload_2018-1-26_8-3-27.png
 
My formula does exactly that ?
You may need to adjust the input cell to your data?

It takes the right 5 characters

GraH's solution also takes the right 5 characters

If only 4 are red, both will fail

There is no way of selecting color with PQ or Formula
It can be done using VBA
 
Last edited:
If you want to get the red part of a string that isn't 5 characters long try:

Code:
Function Get_Red(ByRef target As Variant) As String
'Get Red part of string
Dim i As Integer
For i = 1 To Len(target)
    If target.Characters(Start:=i, Length:=1).Font.Color = 255 Then
        Get_Red = Right(target, Len(target) - i + 1)
        Exit Function
    End If
Next
End Function

To use it copy and paste the code into a Code Module in VBA
in Excel =Get_Red(A1)
 
Back
Top