• Add ‘n=’ to an ActiveCell (officexp, win 2000)

    Home » Forums » AskWoody support » Productivity software by function » Visual Basic for Applications » Add ‘n=’ to an ActiveCell (officexp, win 2000)

    Author
    Topic
    #367579

    I have a cell with the number 317 in it. I want to add n = before the 317 so it become n = 317. How do i do this using vba? Thanks

    Viewing 1 reply thread
    Author
    Replies
    • #573528

      If the cell is A1 on worksheet Sheet1, then:

          Worksheets("Sheet1").Range("A1").Value = "n=" & Worksheets("Sheet1").Range("A1").Value
      

      If you really meant the active cell as the subject says, then:

          ActiveCell.Value = "n=" & ActiveCell.Value
      
      • #573611

        However, in either case, you no longer have a number, you have a string.

    • #573680

      In order to keep the 317 in the cell as a number, I would just change the format:

          Selection.NumberFormat = """n=""General"
      
    Viewing 1 reply thread
    Reply To: Add ‘n=’ to an ActiveCell (officexp, win 2000)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: