View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Leith Ross[_671_] Leith Ross[_671_] is offline
external usenet poster
 
Posts: 1
Default method 'range' of object'_global' failed


Hello cedtech23,

If your macro will always be run on the active worksheet, change your
code to this....


Code:
--------------------

Public Function ColorBorder(chgcell As String)
ActiveSheet.Range(chgcell).Select
With Selection.Font
.Name = "Arial"
.FontStyle = "Bold"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = 3
End With
End Function
--------------------


If want your code to run on any worksheet regardless if it is the
active sheet, use this code...


Code:
--------------------
Public Function ColorBorder(wks As String, chgcell As String)
Worksheets(wks).Range(chgcell).Select
With Selection.Font
.Name = "Arial"
.FontStyle = "Bold"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = 3
End With
End Function
--------------------


Sincerely,
Leith Ross


--
Leith Ross
------------------------------------------------------------------------
Leith Ross's Profile: http://www.excelforum.com/member.php...o&userid=18465
View this thread: http://www.excelforum.com/showthread...hreadid=563506