• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Ambiquous Name Detected Error

Dokat

Member
Hi,

I have below 2 codes in the same workbooksheet. When i try to run it gives me Compile error: Ambiguous name detected: Worksheet_Change error for the second code. Is there a way to combine these 2 codes of fix the error message

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    Dim R1 As Range, R2 As Range, R3 As Range, R4 As Range
    Set R1 = Range("CG1")
    Set R2 = Range("CF1")
    Set R3 = Range("E2")
    Set R4 = Range("D2")
    If R1.Value = 1 Then
        R3.Interior.Color = vbWhite
    ElseIf R2.Value = 1 Then
        R4.Interior.Color = vbWhite
      Else
        R3.Interior.Color = 6
    End If
End Sub

Code:
[B]Private Sub Worksheet_Change(ByVal Target As Range)[/B]
ActiveSheet.Shapes.Range(Array("Group42")).Select
Selection.ShapeRange.Rotation = Range("D10").Value * 245
ActiveCell.Select
End Sub
 
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    Dim R1 As Range, R2 As Range, R3 As Range, R4 As Range
    Set R1 = Range("CG1")
    Set R2 = Range("CF1")
    Set R3 = Range("E2")
    Set R4 = Range("D2")
    If R1.Value = 1 Then
        R3.Interior.Color = vbWhite
    ElseIf R2.Value = 1 Then
        R4.Interior.Color = vbWhite
      Else
        R3.Interior.Color = 6
    End If

ActiveSheet.Shapes.Range(Array("Group42")).Select
Selection.ShapeRange.Rotation = Range("D10").Value * 245
ActiveCell.Select
End Sub
 
Thank you. I tried it but below code didnt work

Code:
ActiveSheet.Shapes.Range(Array("Group 42")).Select
Selection.ShapeRange.Rotation = Range("D9").Value * 245
ActiveCell.Select
 
What error did you receive and what is highlighted in the macro ?

It will be easier also if you post your workbook.
 
I made an adjustment to the code and it is working now. Is there a way to write a code to lock rotation between 0% to 245%. Thanks

What error did you receive and what is highlighted in the macro ?

It will be easier also if you post your workbook.
 
Back
Top