Numrows function is not working in Excel 2010 VBA

misterno

Board Regular
Joined
Mar 16, 2009
Messages
78
It stops at numrows line

Please help

Dim ws As Worksheet
Dim rgQuotes As Range
Dim rgPasteTo As Range
Dim rgTable As Range
Dim rgBid As Range
Dim nRows As Integer
' Initialize
'
With Application
.EnableEvents = False
.ScreenUpdating = False
End With
' Set objects
Set ws = ActiveWorkbook.Sheets("Filter")
Set rgPasteTo = ws.Range("PasteTo")

' Clean up
ActiveWorkbook.Sheets("Dump").Activate
Set rgQuotes = ActiveSheet.Range("FilteredQuotes")

If IsEmpty(rgQuotes) Then ' Error handling
Range(rgQuotes, rgQuotes.Offset(1, 0)).Value = "Quotes will come here..."
End If

numRows = Range(rgQuotes, rgQuotes.End(xlDown)).Rows.Count
Set rgTable = rgQuotes.Resize(numRows, 6)
rgTable.ClearContents
Set rgTable = Nothing
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
numRows isn't a function, it's a variable and this line of code is trying to assign a value to it.
Code:
numRows = Range(rgQuotes, rgQuotes.End(xlDown)).Rows.Count

What error do you get on that line?
 
Upvote 0
It stops at numrows line

Please help

Dim ws As Worksheet
Dim rgQuotes As Range
Dim rgPasteTo As Range
Dim rgTable As Range
Dim rgBid As Range
Dim nRows As Integer
' Initialize
'
With Application
.EnableEvents = False
.ScreenUpdating = False
End With
' Set objects
Set ws = ActiveWorkbook.Sheets("Filter")
Set rgPasteTo = ws.Range("PasteTo")

' Clean up
ActiveWorkbook.Sheets("Dump").Activate
Set rgQuotes = ActiveSheet.Range("FilteredQuotes")

If IsEmpty(rgQuotes) Then ' Error handling
Range(rgQuotes, rgQuotes.Offset(1, 0)).Value = "Quotes will come here..."
End If

numRows = Range(rgQuotes, rgQuotes.End(xlDown)).Rows.Count
Set rgTable = rgQuotes.Resize(numRows, 6)
rgTable.ClearContents
Set rgTable = Nothing
What happens if you replace "Integer" with "Long" in the code line I highlighted in red?
 
Upvote 0
numRows isn't a function, it's a variable and this line of code is trying to assign a value to it.
Code:
numRows = Range(rgQuotes, rgQuotes.End(xlDown)).Rows.Count

What error do you get on that line?

This is the error;

Compile error

Can't find project or library
--------------------

Sorry I forgot to add, I just converted from 2007 excel to 2010

I think 2010 VBA does not recognize some 2007 vba
 
Upvote 0
Can you post all the code for this sub/function?

Also, take a look under Tools>References...

If you see anything there marked as MISSING note it's name then uncheck it and try the code again.
 
Upvote 0

Forum statistics

Threads
1,214,641
Messages
6,120,691
Members
448,978
Latest member
rrauni

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top