LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 72
Default Ambiguous Name detected?

I'm working on a macro that brings up a userform, gets the info from
the user, then goes back to the General Module to create a new
spreadsheet based on the user's input. I have the userform working
fine, but now I'm getting an "Ambigous Name detected" when I run the
macro. Here is the userform code:

Option Explicit

Private Sub btnCancel_Click()
End
End Sub

Private Sub btnTop21BOS_Click()

End Sub

Private Sub CheckBox1_Click()
bHdr = True
End Sub

Sub OKButton_Click()
Dim rFndCell As Range
Dim lStrDif As Long
Dim s1stCtyName As String

If btnTop10BOS Then lTop = 10 <======= AMBIGUOUS NAME DETECTED
If btnTop21BOS Then lTop = 21
If btnTop10MidBOS Then lTop = 3

If lTop = 0 Then
MsgBox "Please select the type of extraction (i.e., Top 10, BOS)
you want."
Exit Sub
End If

On Error Resume Next
Set rFirstData = Range(reDataStrt.Text)
If Err < 0 Then
MsgBox "Invalid Range Selected"
reDataStrt.SetFocus
On Error GoTo 0
Exit Sub
End If

Set rFndCell = rFirstData.Rows(1).Find(What:="Adams", _
LookIn:=xlValues, _
LookAt:=xlPart, _
MatchCase:=False)
If rFndCell Is Nothing Then
MsgBox "The first row of data should include Adams County. " _
& "Please select the correct row."
Exit Sub
End If

s1stCtyName = rFndCell.Value

If UCase(s1stCtyName) Like "*ADAMS" Then
lStrDif = Len(s1stCtyName) - 5
s1stCtyName = Right(s1stCtyName, Len(s1stCtyName) - lStrDif)
Else
If MsgBox("No ADAMS county found in county list!",
vbRetryCancel) _
= vbCancel Then
Exit Sub
Else
Application.ScreenUpdating = True

End If

End If

If rFirstData Is Nothing Then
Exit Sub 'user hit cancel
End If

lLastCol = rFirstData.Columns(.Columns.Count).Column

If cbHdr = True Then bHdr = True

End If
uf1021Mid.Hide

End Sub

Here is the General Module code:

Option Explicit
Public bHdr As Boolean
Public lTop As Long
Public rFirstData As Range


Sub Extr10L()
Dim wbCtyData As Workbook
Dim oWS As Object
Dim wsTop10List As Worksheet
Dim wsCtyData As Worksheet


Set wsTop10List = ThisWorkbook.Worksheets("CtyLst")
Set wsCtyData = ActiveSheet
Set wbCtyData = ActiveWorkbook

'Test is Mark Top 10 workbook is active
If ActiveWorkbook.Name = ThisWorkbook.Name Then
MsgBox "You have selected the workbook that contains the macro." &
_
Chr(13) & "Please click Ok and select the correct workbook and " &
_
Chr(13) & "worksheet and restart the macro.", vbOKOnly
Exit Sub
End If

'TEST FOR SHEET NAMED "Top"
For Each oWS In wbCtyData.Sheets
If oWS.Name = "Top" Then
If MsgBox("A worksheet named Top already exists in this
workbook." _
& Chr(13) & "Please remove or rename it and run the macro
again.", _
vbOKOnly) = vbOK Then Exit Sub
End If
Next

lTop = 0
bHdr = False

uf1021Mid.Show


End Sub

The General Module code doesn't do much yet, except do some error
trapping and display the userform.

When I get the error, it highlight the "lTop =", including the = sign,
as though VBA has forgotten what an = sign means. Very confused by
this, as I've done the same a hundred times. I think it probably has
something to do with the userform maybe? I did search this group for
"ambiguous", but didn't find anything that seemed relevant. Any ideas
would be greatfully accepted.
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
ambiguous name detected? Derrick Excel Discussion (Misc queries) 7 July 8th 09 07:05 PM
ambiguous selection NeilG Excel Programming 1 July 20th 05 04:26 AM
ambiguous name detected mark Excel Programming 4 February 4th 04 03:01 PM
Ambiguous Name Detected Nigel[_5_] Excel Programming 11 October 26th 03 09:59 AM
Ambiguous Name Detected:~ jaf Excel Programming 0 September 12th 03 12:56 AM


All times are GMT +1. The time now is 11:51 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"