PDA

View Full Version : macro help



oleg_v
03-09-2010, 04:28 PM
hi
i am trying to use this macro
in excel:

Private Sub O6_Click()
Selection.Font.Name = "ARIAL"
Selection.Font.Size = 12
Selection.TypeText Text:="6"
End Sub

it gives me:

object does not support this proporty or method

what can i do to fix this??


TNX

Paul_Hossler
03-09-2010, 05:26 PM
Selection can be anything, a shape or a range etc.

Were you thinking ActiveCell.Font. etc.?

That would apply your macro to the currently selected cell


Your could use


If Not TypeOf Selection Is Range Then Exit Sub


Paul

mbarron
03-09-2010, 05:27 PM
The TypeText is a Word Method, not an Excel method.

Selection = "6" does the same thing.

oleg_v
03-09-2010, 11:20 PM
HI
IT WORKS
BUT I HAVE A USRFORM WITH BUTTONS IN THE WORD WHEN I CLICK EACH BUTTON IT WRITES ME A LETTER WHEN I CLICK ATHER BOTTUN IT WRITES ME A LETTER NEXT TO IT KNOW IN EXCEL EACH NEW CLICK REPLACES ME THE OLD ONE


WHAT CAN I DO?