+ Reply to Thread
Results 1 to 3 of 3

Worksheet calculate event

Hybrid View

  1. #1
    Registered User
    Join Date
    12-10-2012
    Location
    Toronto
    MS-Off Ver
    Excel 2010
    Posts
    68

    Worksheet calculate event

    Worksheet calculate event doesn't let me change values on another sheet "Queries". When I do gives me error 438, object doesn’t support this property or method.

    Private Sub Worksheet_Calculate()
     
     i = 0
        numb = 18
        For i = 80 To 103
        
        
        Worksheets("Sheet1").Shapes.Range(Array("TextBox " & i)).Select
        With Selection.ShapeRange.Fill                ''''''''''''''''HIGHLIGHTS THIS LINE
        .Visible = msoTrue
                  If Worksheets("Queries").Range(Worksheets("Queries").Cells(2, numb), Worksheets("Queries") _
                  .Cells(2, numb)) = 1 Then
                 
                 .ForeColor.RGB = RGB(0, 255, 0)
                  Else
                 .ForeColor.RGB = RGB(205, 205, 193)
                  End If
        .Solid
        End With
        numb = numb + 1
        Next i
        
    End Sub

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,645

    Re: Worksheet calculate event

    I don't think it's the calculate event preventing you doing it.

    What you need to do is reference the shapes on the other sheet and not use Selection.
    Private Sub Worksheet_Calculate()
    Dim I As Long
    Dim numb As Long
    
        I = 0
        numb = 18
        For I = 80 To 103
    
            With Worksheets("Sheet1").Shapes("TextBox " & I).OLEFormat.Object.ShapeRange.Fill                ''''''''''''''''HIGHLIGHTS THIS LINE
                .Visible = msoTrue
                If Worksheets("Queries").Cells(2, numb) = 1 Then
    
                    .ForeColor.RGB = RGB(0, 255, 0)
                Else
                    .ForeColor.RGB = RGB(205, 205, 193)
                End If
                .Solid
            End With
            numb = numb + 1
        Next I
    
    End Sub
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    12-10-2012
    Location
    Toronto
    MS-Off Ver
    Excel 2010
    Posts
    68

    Re: Worksheet calculate event

    Oh yea I was trying to do it but lack of knowledge prevented me. BUT YES THIS WORKS!!!!!!! AW YEAH! Thank you so much Norie. I really hope i don't encounter a problem now.

+ Reply to Thread

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