Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Ayo Ayo is offline
external usenet poster
 
Posts: 489
Default Compile error. Need Help with this UDF !!!!!!!!!!!!!!!

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Compile error. Need Help with this UDF !!!!!!!!!!!!!!!

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
  #3   Report Post  
Posted to microsoft.public.excel.programming
Ayo Ayo is offline
external usenet poster
 
Posts: 489
Default Compile error. Need Help with this UDF !!!!!!!!!!!!!!!

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
.

  #4   Report Post  
Posted to microsoft.public.excel.programming
Ayo Ayo is offline
external usenet poster
 
Posts: 489
Default Compile error. Need Help with this UDF !!!!!!!!!!!!!!!

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
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
Bubble sort Error (Compile Error: Type Mismtach) Excel Monkey[_2_] Excel Programming 6 April 24th 09 12:16 AM
VBAProject name compile error, not defined at compile time Matthew Dodds Excel Programming 1 December 13th 05 07:17 PM
error message: compile error, argument not optional Pierre via OfficeKB.com Excel Programming 3 September 5th 05 03:45 PM
How do I get rid of "Compile error in hidden module" error message David Excel Discussion (Misc queries) 4 January 21st 05 11:39 PM


All times are GMT +1. The time now is 02:45 PM.

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

About Us

"It's about Microsoft Excel"