locked
Font Formatting RRS feed

  • Question

  • Greetings - 

    Does anyone know if and/or how just the highlighted portion of code below can be formatted in Italic?

    Sheets("Recruitment").Range("B53").Value = Sheets("Recruitment").Range("Q10") & " (" & fOSUserName() & ")"

    Monday, September 26, 2016 8:10 PM

Answers

  • Hi,

    What is your "fOSUserName()"?  Does it return string?

    You could try the following to format part of cells.

    Sub it()
    ActiveSheet.Range("A1").Value = ActiveSheet.Range("A2").Value & " (" & "test" & ")"
    Dim a As Long
    Dim b As Long
    a = InStr(1, ActiveSheet.Range("A1").Value, "(")
    b = InStr(1, ActiveSheet.Range("A1").Value, ")")
    ActiveSheet.Range("A1").Characters(Start:=a, Length:=b).Font.Italic = True
    End Sub

    Tuesday, September 27, 2016 2:50 AM

All replies

  • Hi,

    What is your "fOSUserName()"?  Does it return string?

    You could try the following to format part of cells.

    Sub it()
    ActiveSheet.Range("A1").Value = ActiveSheet.Range("A2").Value & " (" & "test" & ")"
    Dim a As Long
    Dim b As Long
    a = InStr(1, ActiveSheet.Range("A1").Value, "(")
    b = InStr(1, ActiveSheet.Range("A1").Value, ")")
    ActiveSheet.Range("A1").Characters(Start:=a, Length:=b).Font.Italic = True
    End Sub

    Tuesday, September 27, 2016 2:50 AM
  • Hi Asadulla - 

    Thank you for your assistance :) The "fOSUserName()"  actually returns the username of the current user logged into the computer in which the workbook is being accessed.

    I will give your suggestion a try. I think I may have found another way around this but your suggestion may prove helpful as well.

    I shall let you know how it works. Thanks again for your assistance :)

    Tuesday, September 27, 2016 5:02 PM