Insert Numerical One to Specified Cell

User avatar
adam
SilverLounger
Posts: 2347
Joined: 23 Feb 2010, 12:07

Insert Numerical One to Specified Cell

Post by adam »

Hi anyone,

I'm trying to clear the contents of the cell N16 of the active sheet and insert Numerical 01 to the same cell with a macro code. Here's the code I've got so far.

Code: Select all

Sub ClearCell()
    Range("N16").Clear
End Sub
How could I add a line to the code so that it clears the contents of the cell and add Numerical 01 to the cell.

Any help on this would be kindly appreciated.

Thanks in advance.
Best Regards,
Adam

User avatar
StuartR
Administrator
Posts: 12615
Joined: 16 Jan 2010, 15:49
Location: London, Europe

Re: Insert Numerical One to Specified Cell

Post by StuartR »

Something like...

Code: Select all

Sub ClearCell()
    With Range("N16")
        .Clear
        .Value = 1
        .NumberFormat = "00"
    End With
End Sub
StuartR


User avatar
adam
SilverLounger
Posts: 2347
Joined: 23 Feb 2010, 12:07

Re: Insert Numerical One to Specified Cell

Post by adam »

Thanks for the help.Stuart. I really appreciate it.
Best Regards,
Adam