Thread
:
ambiguous name detected?
View Single Post
#
5
Posted to microsoft.public.excel.misc
Don Guillett
external usenet poster
Posts: 10,124
ambiguous name detected?
You DON'T. You incorporate both into ONE.
--
Don Guillett
Microsoft MVP Excel
SalesAid Software
"Anders" wrote in message
...
Hi J.
This is pretty simple I'm assuming.
I've got the ambiguous name detected error coming and I know why, I just
don't know how to fix it. I've got Sheet 1, coded with the following 2
(of
many) macros (they are in object sheet1 and not in a module - to which I
don't know the difference, which is better?) They both have the same
name..Private Sub Worksheet_Change (ByVal Target as Range) - but when I
try
to change either name, (e.g to ..._Change1 ...or ...rowheightchange...) it
won't work. How can I change the name so both work?
TIA.
Macros Below.
Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo ws_exit:
Application.EnableEvents = False
With Target
If .Column = 8 Or 9 Or 10 Then
Select Case .Value
Case "Not Started":
.Interior.ColorIndex = 2 'White
.Font.ColorIndex = 1
Case "Completed":
.Interior.ColorIndex = 5 'Blue
.Font.ColorIndex = 2
Case "Manageable Issues":
.Interior.ColorIndex = 6 'Yellow
.Font.ColorIndex = 1
Case "Significant Issues":
.Interior.ColorIndex = 3 'Red
.Font.ColorIndex = 2
Case "On Track":
.Interior.ColorIndex = 10 ' Green
.Font.ColorIndex = 2
End Select
End If
End With
ws_exit:
Application.EnableEvents = True
End Sub
__
Private Sub Worksheet_Change(ByVal Target As Range)
Dim NewRwHt As Single
Dim cWdth As Single, MrgeWdth As Single
Dim c As Range, cc As Range
Dim ma As Range
With Target
If .MergeCells And .WrapText Then
Set c = Target.Cells(1, 1)
cWdth = c.ColumnWidth
Set ma = c.MergeArea
For Each cc In ma.Cells
MrgeWdth = MrgeWdth + cc.ColumnWidth
Next
Application.ScreenUpdating = False
ma.MergeCells = False
c.ColumnWidth = MrgeWdth
c.EntireRow.AutoFit
NewRwHt = c.RowHeight
c.ColumnWidth = cWdth
ma.MergeCells = True
ma.RowHeight = NewRwHt
cWdth = 0: MrgeWdth = 0
Application.ScreenUpdating = True
End If
End With
End Sub
--
I''ve encountered an error and I need to close for the weekend :)
"JLatham" wrote:
It would help to see the code and know where it was put.
Ambiguous name usually means you have two routines with the same name
within
the same 'scope'.
Also, worksheets can have an event associated with a change in a cell on
the
sheet, it would be within the worksheet's code module. It would be named
Private Sub Worksheet_Change(...)
'code to execute when a change occurs on the worksheet
End Sub
Look in your VBA project for the word Change and see where it appears,
and
that will probably clue you in on either 2 routines with the same name,
or if
VBA is being confused somehow by a routine named Change and the
Worksheet_Change() event processor for that worksheet.
"Derrick" wrote:
i have a set of code/macro called Change for my sheets, which hides
rows/enters formulas for whenever a cell 'b3' is changed to another
option
from a validated list.
however, for some reason now, a Microsoft Visual Basic notice box pops
up
and says "Ambiguous name detected: Change" when i imput data into any
cell.
any ideas as to why?
Reply With Quote
Don Guillett
View Public Profile
Find all posts by Don Guillett