Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3
Default App_change event to open all work book

Hi
I am filled interior color on the cell typing specified mentioned
character(as below)
I'll expect fill the color every open workbook, but i fills only one
cell
what's error in my code

I used this code on Eventclass (Class Modules)

Option Explicit

Public WithEvents App As Application

Private Sub App_NewWorkbook(ByVal Wb As Excel.Workbook)
MsgBox "Application Event: New Workbook: " & Wb.Name
End Sub

Private Sub App_SheetActivate(ByVal Sh As Object)
MsgBox "Application Event: SheetActivate: " & Sh.Name
End Sub

Public Sub App_WorkbookOpen(ByVal Wb As Excel.Workbook)
MsgBox "Application Event: WorkbookOpen: " & Wb.Name
End Sub

Public Sub App_SheetChange(ByVal Sh As Object, ByVal Target As
Excel.Range)
Dim cell As Range
Dim charArr As Variant
Dim colorArr As Variant
Dim i As Long

charArr = Array("s", "d", "t", "c", "c-", "pc")
colorArr = Array(3, 4, 5, 6, 7, 8)
Application.EnableEvents = False

For Each cell In Target
With cell
.Interior.ColorIndex = xlColorIndexNone
For i = 0 To UBound(charArr)
If .Value = charArr(i) Then
MsgBox ("first")
.Interior.ColorIndex = colorArr(i)
Exit For
End If
Next i
End With
Next cell
End Sub
-------------------------------------------------
This work book code

Option Explicit

Dim Appclass As New EventClass

Private Sub Workbook_Open()
Set Appclass.App = Application
End Sub

please suggest me, how to fill every open workbook?

Thanks
Venky

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default App_change event to open all work book

You turn events off, but never turn them back on.

You can either add
application.enableevents = true
right before the End Sub in the app_sheetchange event procedure.

Or because formatting doesn't cause an event to fire, you could remove the
application.enableevents = false
line.





wrote:

Hi
I am filled interior color on the cell typing specified mentioned
character(as below)
I'll expect fill the color every open workbook, but i fills only one
cell
what's error in my code

I used this code on Eventclass (Class Modules)

Option Explicit

Public WithEvents App As Application

Private Sub App_NewWorkbook(ByVal Wb As Excel.Workbook)
MsgBox "Application Event: New Workbook: " & Wb.Name
End Sub

Private Sub App_SheetActivate(ByVal Sh As Object)
MsgBox "Application Event: SheetActivate: " & Sh.Name
End Sub

Public Sub App_WorkbookOpen(ByVal Wb As Excel.Workbook)
MsgBox "Application Event: WorkbookOpen: " & Wb.Name
End Sub

Public Sub App_SheetChange(ByVal Sh As Object, ByVal Target As
Excel.Range)
Dim cell As Range
Dim charArr As Variant
Dim colorArr As Variant
Dim i As Long

charArr = Array("s", "d", "t", "c", "c-", "pc")
colorArr = Array(3, 4, 5, 6, 7, 8)
Application.EnableEvents = False

For Each cell In Target
With cell
.Interior.ColorIndex = xlColorIndexNone
For i = 0 To UBound(charArr)
If .Value = charArr(i) Then
MsgBox ("first")
.Interior.ColorIndex = colorArr(i)
Exit For
End If
Next i
End With
Next cell
End Sub
-------------------------------------------------
This work book code

Option Explicit

Dim Appclass As New EventClass

Private Sub Workbook_Open()
Set Appclass.App = Application
End Sub

please suggest me, how to fill every open workbook?

Thanks
Venky


--

Dave Peterson
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro doesn't work when used as Workbook Open event Phil Excel Discussion (Misc queries) 2 October 20th 06 02:42 PM
I was messing arround with the VBA and now I get the macro warning when I open the work book but when... Marc New Users to Excel 2 June 6th 05 08:08 AM
i want to print 70 work book and i dont want to open each n print sid Excel Discussion (Misc queries) 0 April 28th 05 12:08 PM
Is there away to keep "auto save" from jumping to the first work sheet in the work book? Marc New Users to Excel 2 April 21st 05 01:27 AM
simultaneously work in a work book with other users Sweets Excel Discussion (Misc queries) 1 April 18th 05 07:35 PM


All times are GMT +1. The time now is 01:19 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"