Object Required ? Help Please

AlaskanVBA

New Member
Joined
Mar 27, 2011
Messages
6
I'm receiving a 'RunTime Error 424 : Object Required" on the following line:
F = Application.WorksheetFunction.CountIf(R4C9.Resize(FinalRow9, 0), RiC1)
Any advice would be greatly appreciated?

Below is the full code
----

Sub SecondaryC()
Dim WSPC As Worksheet
Dim WSSI As Worksheet

Set WSPC = Worksheets("PrimaryCreation")
Set WSSI = Worksheets("SecondaryInput")
FinalRowC123 = WSSI.Cells(Rows.Count, 1).End(xlUp).Row
FinalRowC9O = WSSI.Cells(Rows.Count, 9).End(xlUp).Row
FinalRowC9F = WSSI.Cells(Rows.Count, 9).End(xlUp).Row
'testing new code

For i = 4 To FinalRowC123
Sec = WSSI.Cells(i, 3)
FinalRowC123 = WSSI.Cells(Rows.Count, 3).End(xlUp).Row

Cells(i, 1).Resize(1, 7).Select
'Find out if From and To inputs are primary or secondary joints'

'Error on next code line?

F = Application.WorksheetFunction.CountIf(R4C9.Resize(5, 0), RiC1)

---------
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
Your resize statement is faulty and may be causing the error'
Rich (BB code):
Resize(FinalRow9, 0)
The highlighted argument must be at least 1 (it's the number of columns in the resized range and can't be 0).
 
Upvote 0
Joe, Appreciate your help but it seems to still not work.
Am I not declaring an object somewhere?

F = Application.WorksheetFunction.CountIf(R4C9.Resize(FinalRowC9O, 1), RiC1)

The above still shows the 'object required' error.
 
Upvote 0
Try this:
Code:
 Dim rng As Range 
Set rng = Range("I4").Resize(FinalRowC90, 1) 
F = Application.WorksheetFunction.CountIf(rng, Cells(i, 1))
 
Upvote 0
Worked like a charm! Thank you for reminding me to dimension more often - I'll make sure to remember this going forward.



Code:

test
 
Upvote 0

Forum statistics

Threads
1,224,538
Messages
6,179,412
Members
452,912
Latest member
alicemil

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