EXCEL VBA code to store value of string which is lying just after the Dash or hyphen

  • Hi,

    could you pls help me to write a vba code in excel to store a value in a variable from a cell which is just after the dash or hyphen

    example:


    AB - XYZ


    here am trying to extract only XYZ.


    Am trying with following

    MyVal = Mid(Worksheets("Sheet1").Cells(lr, "AG"), InStr(Worksheets("Sheet1").Cells(lr, "AG"), "-")+1, Len(Worksheets("AT Provision").Cells(lr, "AG")))


    (Here lr is Lastrow)


    Thanks

    Sanjeev

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!