Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Where am I going wrong?

Status
Not open for further replies.

makavelli2

IS-IT--Management
Feb 25, 2000
7
US
I have a program that is getting a compile errror Sub or Function not defined. Please advise. I have 3 excel programs that run at onece, then the complied information is posted to one file, here is the segment of code that is getting the error.<br>*********************************************<br>Private Function InitColumnArrays() As Boolean<br><br>&nbsp;&nbsp;&nbsp;&nbsp;Dim nColumns As Integer<br>&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;InitColumnArrays = False<br>&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;nColumns = m_sheetEquity.UsedRange.Columns.Count<br>&nbsp;&nbsp;&nbsp;&nbsp;ReDim m_aTopRtgToEquity(1 To nColumns)<br>&nbsp;&nbsp;&nbsp;&nbsp;ReDim m_aTopTrToEquity(1 To nColumns)<br>&nbsp;&nbsp;&nbsp;&nbsp;ReDim m_aTrpAvgToEquity(1 To nColumns)<br><br>&nbsp;&nbsp;&nbsp;&nbsp;If Not InitColumnArray(m_aTopRtgToEquity, ThisWorkbook.Worksheets(&quot;Equity Template&quot;), 2, m_sheetTopRtg) Then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Exit Function<br>&nbsp;&nbsp;&nbsp;&nbsp;End If<br>&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;If Not InitColumnArray(m_aTopTrToEquity, ThisWorkbook.Worksheets(&quot;Equity Template&quot;), 3, m_sheetTopTr) Then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Exit Function<br>&nbsp;&nbsp;&nbsp;&nbsp;End If<br>&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;If Not InitColumnArray(m_aTrpAvgToEquity, ThisWorkbook.Worksheets(&quot;Equity Template&quot;), 4, m_sheetTrpAvg) Then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Exit Function<br>&nbsp;&nbsp;&nbsp;&nbsp;End If<br>&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;nColumns = m_sheetBond.UsedRange.Columns.Count<br>&nbsp;&nbsp;&nbsp;&nbsp;ReDim m_aTopRtgToBond(1 To nColumns)<br>&nbsp;&nbsp;&nbsp;&nbsp;ReDim m_aTopTrToBond(1 To nColumns)<br>&nbsp;&nbsp;&nbsp;&nbsp;ReDim m_aTrpAvgToBond(1 To nColumns)<br><br>&nbsp;&nbsp;&nbsp;&nbsp;If Not InitColumnArray(m_aTopRtgToBond, ThisWorkbook.Worksheets(&quot;Bond Template&quot;), 2, m_sheetTopRtg) Then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Exit Function<br>&nbsp;&nbsp;&nbsp;&nbsp;End If<br>&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;If Not InitColumnArray(m_aTopTrToBond, ThisWorkbook.Worksheets(&quot;Bond Template&quot;), 3, m_sheetTopTr) Then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Exit Function<br>&nbsp;&nbsp;&nbsp;&nbsp;End If<br>&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;If Not InitColumnArray(m_aTrpAvgToBond, ThisWorkbook.Worksheets(&quot;Bond Template&quot;), 4, m_sheetTrpAvg) Then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Exit Function<br>&nbsp;&nbsp;&nbsp;&nbsp;End If<br>&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;InitColumnArrays = True<br><br>End Function not find column &quot; & ThisWorkbook.Worksheets(&quot;Keys&quot;).Cells(3, 2).Value & &quot; in worksheet &quot; & m_sheetTrpAvg.Name<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Exit Function<br>&nbsp;&nbsp;&nbsp;&nbsp;End If
 
<br>is it the call InitColumnArray() that causes the problem if so is this because you have called the function InitColumnArray<b>s</b>()<br><br>if this is not the reason and you have another function called InitColumnArray() then can you give me a little more detail about the error e.g what line it is caused on etc, a copy of the functions that it calls would also be useful.<br><br><br>Hope this helps<br><br>
 
Vince, Thanks!<br>Actually i realized I sent to code I was updating, I changed the InitialColumnArrays() to plural...sorry about that. I am recieving an error that says identifier under cursor not recognized.&nbsp;&nbsp;The application was written in Excel95, it does not work in Excel97. I am ready to scrap it, but my boss wants me to hammer it out. Here is the new code.<br>*********************************************************Private Function InitColumnArrays() As Boolean<br><br>&nbsp;&nbsp;&nbsp;&nbsp;Dim nColumns As Integer<br>&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;InitColumnArrays = False<br>&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;nColumns = m_sheetEquity.UsedRange.Columns.Count<br>&nbsp;&nbsp;&nbsp;&nbsp;ReDim m_aTopRtgToEquity(1 To nColumns)<br>&nbsp;&nbsp;&nbsp;&nbsp;ReDim m_aTopTrToEquity(1 To nColumns)<br>&nbsp;&nbsp;&nbsp;&nbsp;ReDim m_aTrpAvgToEquity(1 To nColumns)<br><br>&nbsp;&nbsp;&nbsp;&nbsp;If Not InitColumnArrays(m_aTopRtgToEquity, ThisWorkbook.Worksheets(&quot;Equity Template&quot;), 2, m_sheetTopRtg) Then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Exit Function<br>&nbsp;&nbsp;&nbsp;&nbsp;End If<br>&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;If Not InitColumnArrays(m_aTopTrToEquity, ThisWorkbook.Worksheets(&quot;Equity Template&quot;), 3, m_sheetTopTr) Then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Exit Function<br>&nbsp;&nbsp;&nbsp;&nbsp;End If<br>&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;If Not InitColumnArrays(m_aTrpAvgToEquity, ThisWorkbook.Worksheets(&quot;Equity Template&quot;), 4, m_sheetTrpAvg) Then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Exit Function<br>&nbsp;&nbsp;&nbsp;&nbsp;End If<br>&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;nColumns = m_sheetBond.UsedRange.Columns.Count<br>&nbsp;&nbsp;&nbsp;&nbsp;ReDim m_aTopRtgToBond(1 To nColumns)<br>&nbsp;&nbsp;&nbsp;&nbsp;ReDim m_aTopTrToBond(1 To nColumns)<br>&nbsp;&nbsp;&nbsp;&nbsp;ReDim m_aTrpAvgToBond(1 To nColumns)<br><br>&nbsp;&nbsp;&nbsp;&nbsp;If Not InitColumnArrays(m_aTopRtgToBond, ThisWorkbook.Worksheets(&quot;Bond Template&quot;), 2, m_sheetTopRtg) Then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Exit Function<br>&nbsp;&nbsp;&nbsp;&nbsp;End If<br>&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;If Not InitColumnArrays(m_aTopTrToBond, ThisWorkbook.Worksheets(&quot;Bond Template&quot;), 3, m_sheetTopTr) Then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Exit Function<br>&nbsp;&nbsp;&nbsp;&nbsp;End If<br>&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;If Not InitColumnArrays(m_aTrpAvgToBond, ThisWorkbook.Worksheets(&quot;Bond Template&quot;), 4, m_sheetTrpAvg) Then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Exit Function<br>&nbsp;&nbsp;&nbsp;&nbsp;End If<br>&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;InitColumnArrays = True<br><br>End Function<br><br>Private Function InitColumnArrays(arrays() As Integer, sheetTemplate As Worksheet, nTemplateRow As Integer, sheetSource As Worksheet) As Boolean<br><br>&nbsp;&nbsp;&nbsp;&nbsp;Dim sColumnName As String<br>&nbsp;&nbsp;&nbsp;&nbsp;Dim cellFind As range<br>&nbsp;&nbsp;&nbsp;&nbsp;Dim i As Integer<br>&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;InitColumnArrays = False<br>&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;For i = 1 To UBound(arrays)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sColumnName = sheetTemplate.Cells(nTemplateRow, i + 1).Value<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;If sColumnName = &quot;--&quot; Then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;arrays(i) = -1<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ElseIf sColumnName = &quot;&quot; Then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;arrays(i) = 0<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ElseIf FindInRange(sColumnName, sheetSource.Rows(&quot;1:1&quot;), cellFind) Then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;arrasy(i) = cellFind.Column<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MsgBox &quot;Could not find column &quot; & sColumnName & &quot; in worksheet &quot; & sheetSource.Name<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Exit Function<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;End If<br>&nbsp;&nbsp;&nbsp;&nbsp;Next i<br><br>&nbsp;&nbsp;&nbsp;&nbsp;InitColumnArray = True<br><br>End Function<br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top