View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default Can I code Styles

You can test for it first and then rebuild it using those recorded statements:

Option Explicit
Sub testme()

Dim myStyle As Style

Set myStyle = Nothing
On Error Resume Next
Set myStyle = ActiveWorkbook.Styles("Currency")
On Error GoTo 0

If myStyle Is Nothing Then
'use your recorded code here to add the style
Else
'it's already there, do nothing special
End If

End Sub




Wired Hosting News wrote:

If I run into a situaton where I have an addin formatting cells to a
particular style:

ws.Column("D:D").style = "Currency"

and the workbook that is active at the time does not have that style, is it
possible to code the workbook or add the style to the workbook, prior to
running the rest of the macro?


--

Dave Peterson