PC Review


Reply
Thread Tools Rate Thread

Compile error. Need Help with this UDF !!!!!!!!!!!!!!!

 
 
Ayo
Guest
Posts: n/a
 
      11th Apr 2010
I wrote a function that worked fine before and now all of a sudden I am
getting a "Compile error: Expected array." The problem seem to be with the
line
"startRow(marketNAME)" especially "startRow"
I can't figure out the problem. Please HELP.

Sub getSTARTEND_ROWS()
Dim c As Range, startRow As Long, endRow As Long
Dim marketNAME As String

Worksheets("Lookup Tables").Visible = True
Worksheets("Lookup Tables").Select
For Each c In Worksheets("Lookup Tables").Range("B19:B28")
marketNAME = c
c.Offset(0, 1) = startRow(marketNAME)
c.Offset(0, 2) = lastRow(marketNAME, c.Offset(0, 1))
Next c
Worksheets("Lookup Tables").Visible = False
End Sub

Function startRow(marketNAME As String) As Long
Set STLWS = Worksheets("Sites Task List")
STL_lRow = STLWS.Range("A65536").End(xlUp).Row

For Each c In STLWS.Range("A2:A" & STL_lRow)
If c = marketNAME Then
strRow = c.Row
Exit For
End If
Next c
firstRow = strRow
End Function
 
Reply With Quote
 
 
 
 
Dave Peterson
Guest
Posts: n/a
 
      11th Apr 2010
You've got a variable named startRow (as long) and a function named startRow.

I don't see where the variable is used. I deleted it and still couldn't test
since the LastRow function isn't there.

Ayo wrote:
>
> I wrote a function that worked fine before and now all of a sudden I am
> getting a "Compile error: Expected array." The problem seem to be with the
> line
> "startRow(marketNAME)" especially "startRow"
> I can't figure out the problem. Please HELP.
>
> Sub getSTARTEND_ROWS()
> Dim c As Range, startRow As Long, endRow As Long
> Dim marketNAME As String
>
> Worksheets("Lookup Tables").Visible = True
> Worksheets("Lookup Tables").Select
> For Each c In Worksheets("Lookup Tables").Range("B19:B28")
> marketNAME = c
> c.Offset(0, 1) = startRow(marketNAME)
> c.Offset(0, 2) = lastRow(marketNAME, c.Offset(0, 1))
> Next c
> Worksheets("Lookup Tables").Visible = False
> End Sub
>
> Function startRow(marketNAME As String) As Long
> Set STLWS = Worksheets("Sites Task List")
> STL_lRow = STLWS.Range("A65536").End(xlUp).Row
>
> For Each c In STLWS.Range("A2:A" & STL_lRow)
> If c = marketNAME Then
> strRow = c.Row
> Exit For
> End If
> Next c
> firstRow = strRow
> End Function


--

Dave Peterson
 
Reply With Quote
 
Ayo
Guest
Posts: n/a
 
      12th Apr 2010
Thanks Dave. I found it.

"Dave Peterson" wrote:

> You've got a variable named startRow (as long) and a function named startRow.
>
> I don't see where the variable is used. I deleted it and still couldn't test
> since the LastRow function isn't there.
>
> Ayo wrote:
> >
> > I wrote a function that worked fine before and now all of a sudden I am
> > getting a "Compile error: Expected array." The problem seem to be with the
> > line
> > "startRow(marketNAME)" especially "startRow"
> > I can't figure out the problem. Please HELP.
> >
> > Sub getSTARTEND_ROWS()
> > Dim c As Range, startRow As Long, endRow As Long
> > Dim marketNAME As String
> >
> > Worksheets("Lookup Tables").Visible = True
> > Worksheets("Lookup Tables").Select
> > For Each c In Worksheets("Lookup Tables").Range("B19:B28")
> > marketNAME = c
> > c.Offset(0, 1) = startRow(marketNAME)
> > c.Offset(0, 2) = lastRow(marketNAME, c.Offset(0, 1))
> > Next c
> > Worksheets("Lookup Tables").Visible = False
> > End Sub
> >
> > Function startRow(marketNAME As String) As Long
> > Set STLWS = Worksheets("Sites Task List")
> > STL_lRow = STLWS.Range("A65536").End(xlUp).Row
> >
> > For Each c In STLWS.Range("A2:A" & STL_lRow)
> > If c = marketNAME Then
> > strRow = c.Row
> > Exit For
> > End If
> > Next c
> > firstRow = strRow
> > End Function

>
> --
>
> Dave Peterson
> .
>

 
Reply With Quote
 
Ayo
Guest
Posts: n/a
 
      12th Apr 2010
Thanks Dave. Found it.

"Dave Peterson" wrote:

> You've got a variable named startRow (as long) and a function named startRow.
>
> I don't see where the variable is used. I deleted it and still couldn't test
> since the LastRow function isn't there.
>
> Ayo wrote:
> >
> > I wrote a function that worked fine before and now all of a sudden I am
> > getting a "Compile error: Expected array." The problem seem to be with the
> > line
> > "startRow(marketNAME)" especially "startRow"
> > I can't figure out the problem. Please HELP.
> >
> > Sub getSTARTEND_ROWS()
> > Dim c As Range, startRow As Long, endRow As Long
> > Dim marketNAME As String
> >
> > Worksheets("Lookup Tables").Visible = True
> > Worksheets("Lookup Tables").Select
> > For Each c In Worksheets("Lookup Tables").Range("B19:B28")
> > marketNAME = c
> > c.Offset(0, 1) = startRow(marketNAME)
> > c.Offset(0, 2) = lastRow(marketNAME, c.Offset(0, 1))
> > Next c
> > Worksheets("Lookup Tables").Visible = False
> > End Sub
> >
> > Function startRow(marketNAME As String) As Long
> > Set STLWS = Worksheets("Sites Task List")
> > STL_lRow = STLWS.Range("A65536").End(xlUp).Row
> >
> > For Each c In STLWS.Range("A2:A" & STL_lRow)
> > If c = marketNAME Then
> > strRow = c.Row
> > Exit For
> > End If
> > Next c
> > firstRow = strRow
> > End Function

>
> --
>
> Dave Peterson
> .
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Export report to Excel, Error message "Compile Error: Argument not mc Microsoft Access External Data 0 16th Jul 2009 09:11 PM
VBAProject name compile error, not defined at compile time Matthew Dodds Microsoft Excel Programming 1 13th Dec 2005 07:17 PM
Compile error. in table-level validation expression. (Error 3320) =?Utf-8?B?RG9ubmE=?= Microsoft Access Forms 4 21st Mar 2005 08:13 PM
error message in Winword. ( Compile error in hidden module: AutoE. =?Utf-8?B?TXkgRXJyb3IgUHJvYmxlbQ==?= Microsoft Access Getting Started 1 4th Oct 2004 02:52 AM
excel 2003 error>> compile error in hidden module: ThisWorkbook clayton Microsoft Excel Misc 4 22nd Jun 2004 02:02 AM


Features
 

Advertising
 

Newsgroups
 


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