Results 1 to 7 of 7

LoopThrough Workshhet for Worksheet_change

Threaded View

  1. #1
    Registered User
    Join Date
    05-28-2010
    Location
    India
    MS-Off Ver
    Excel 2003
    Posts
    3

    Unhappy LoopThrough Workshhet for Worksheet_change

    Hi

    I have the following code in my worksheet, which I would like to run through all the sheets automatically, even if there is new sheet added. Also, if you could optimize the following code and for a certain range of cells that would be awesome...Thanks XX

    Also, please mention where i should plug this, in all individual sheets, or in the workbook, or in the module....thanks

    -------------------------------------------------------

    Private Sub Worksheet_Change(ByVal Target As Range)
         '//Written by parry
        Dim c
        If Target.Cells.Count = 1 Then
            Select Case Target.Value
            Case Is >= 1000000000
                Target.Cells.NumberFormat = "##"",""00"",""00"",""00"",""000.00"
            Case Is >= 10000000
                Target.Cells.NumberFormat = "##"",""00"",""00"",""000.00"
            Case Is >= 100000
                Target.Cells.NumberFormat = "##"",""00"",""000.00"
            Case Else
                Target.Cells.NumberFormat = "##,###.00"
            End Select
        Else
            For Each c In Target
                Select Case c.Value
                Case Is >= 1000000000
                    c.NumberFormat = "##"",""00"",""00"",""00"",""000.00"
                Case Is >= 10000000
                    c.NumberFormat = "##"",""00"",""00"",""000.00"
                Case Is >= 100000
                    c.NumberFormat = "##"",""00"",""000.00"
                Case Else
                    c.NumberFormat = "##,###.00"
                End Select
            Next c
        End If
    End Sub
    
    Private Sub Workbook_Open()
    ------------------------------------------------------
    Last edited by suryagoel; 05-28-2010 at 05:09 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1