coliervile
07-24-2006, 06:11 PM
Can anyone explain why when I type Sub TestCharliePeters() I receive a Compile error: Ambiguous name detected: TestCharliePeters? I can type TestCharlesPeters or TestCharleyPeters and it works fine...just wondering why. All of the other names work in sheet1 of the workbook. See attach test workbook:
Sub TestCharliePeters()
Dim Rng As Range
Dim Sh As Worksheet
Dim c As Range
Dim x As Integer
Set Rng = Worksheets("sheet1").Range("A1:A" & Range("A65536").End(xlUp).Row)
Set Sh = Worksheets("sheet10")
' Delete existing data
Sh.Range("A2:A" & Range("A65536").End(xlUp).Row).EntireRow.Clear
x = 2
For Each c In Rng
If c.Value = "CharliePeters" Then
c.EntireRow.Copy Sh.Cells(x, 1)
x = x + 1
End If
Next c
End Sub
Also is there a way to run this when the main database in sheet1 is updated or new data is added through a VB userform? Basically the code copies rows of data to a designated worksheet from worksheet1 when the criteria is met in Column A.
Charlie
Sub TestCharliePeters()
Dim Rng As Range
Dim Sh As Worksheet
Dim c As Range
Dim x As Integer
Set Rng = Worksheets("sheet1").Range("A1:A" & Range("A65536").End(xlUp).Row)
Set Sh = Worksheets("sheet10")
' Delete existing data
Sh.Range("A2:A" & Range("A65536").End(xlUp).Row).EntireRow.Clear
x = 2
For Each c In Rng
If c.Value = "CharliePeters" Then
c.EntireRow.Copy Sh.Cells(x, 1)
x = x + 1
End If
Next c
End Sub
Also is there a way to run this when the main database in sheet1 is updated or new data is added through a VB userform? Basically the code copies rows of data to a designated worksheet from worksheet1 when the criteria is met in Column A.
Charlie