Run Time error 424 in code.

fvisions

Board Regular
Joined
Jul 29, 2008
Messages
191
Office Version
  1. 365
Platform
  1. Windows
I am getting a Run time error 424 Object required for the code line starting with I = Worksheets….
VBA Code:
Sub MoveRowBasedOnCellValue()

Dim xRg As Range
Dim xCell As Range
Dim I As Long
Dim J As Long
Dim K As Long
I = Worksheets("InstallationWKG").UsedRange.Row.Count
J = Worksheets("Notes").UsedRange.Rows.Count
If J = 1 Then
If Appication.worksheetFunctio.CountA(Worksheets("Notes").UsedRange) = 0 Then J = 0
End If
Set xRg = Worksheets("InstallationWKG").Range("v1:v" & I)
On Error Resume Next
Application.ScreenUpdating = False
For K = 1 To xRg.Count
If CStr(xRg(K).Value) = "end" Then
xRg(K).EntireRow.Copy Destination:=Worksheets("Notes").Range("a" & J + 1)
J = J + 1
End If
Next
Application.ScreenUpdating = True
End Sub
 
Last edited by a moderator:

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
It should be Rows not Row
 
Upvote 0
You are also missing an n on worksheetfunction
Remove this line
VBA Code:
 On Error Resume Next
and run the code again.
 
Upvote 0
I think I understand, I checked all my spelling errors, sorry about that and I have the code as follows but nothing is happening?
Code:
Sub MoveRowBasedOnCellValue()
'delete End Items and copy to Notes tab

Dim xRg As Range
Dim xCell As Range
Dim I As Long
Dim J As Long
Dim K As Long
I = Worksheets("InstallationWKG").UsedRange.Rows.Count
J = Worksheets("Notes").UsedRange.Rows.Count
If J = 1 Then
If Appication.WorksheetFunction.CountA(Worksheets("Notes").UsedRange) = 0 Then J = 0
End If
Set xRg = Worksheets("InstallationWKG").Range("v1:v" & I)
' On Error Resume Next
Application.ScreenUpdating = False
For K = 1 To xRg.Count
If CStr(xRg(K).Value) = "end" Then
xRg(K).EntireRow.Copy Destination:=Worksheets("Notes").Range("a" & J + 1)
J = J + 1
End If
Next
Application.ScreenUpdating = True
End Sub
 
Last edited by a moderator:
Upvote 0
Do you have any values in column V that are Exactly "end" (without the quotes) rather than "End", "END","end " etc
 
Upvote 0
Hello, Yes there are some "end" in the col v. I just went back to start over after running my first set of vba for worksheet setup. then ran this again (I changed it to all caps END, as this is important for an upload file.) it is working but one last question (I hope) how to I update the code to paste the rows in row 2 of Notes Tab?
 
Upvote 0
Replace this
VBA Code:
J = Worksheets("Notes").UsedRange.Rows.Count
If J = 1 Then
If Appication.WorksheetFunction.CountA(Worksheets("Notes").UsedRange) = 0 Then J = 0
End If
with
VBA Code:
J = 1
 
Upvote 0
Thank you so much for your patience it worked. Now that I am running this, the vba codes I am using for rows 1 to 488, is there a general code I can use to run code to stop at the end of the data no matter how many rows are used? I have a large code for multiple steps. Should I ask this question as a separate thread? Partial code is below describing the limited row set.
Code:
Sheets("Installation ORIG").Select
    ActiveCell.Range("A1").Select
    Sheets("Installation ORIG").Copy Before:=Sheets(1)
    Sheets("Installation ORIG (2)").Select
    Sheets("Installation ORIG (2)").Name = "Installation wkg"
    Range("A1").Select
    Range("B1").Select
    ActiveCell.FormulaR1C1 = "."
    Range("D1").Select
    ActiveCell.FormulaR1C1 = "."
    Range("J1").Select
    ActiveCell.FormulaR1C1 = "."
    Range("T1").Select
    ActiveCell.FormulaR1C1 = "."
    Range("V1").Select
    Selection.Style = "Normal 19"
    ActiveCell.FormulaR1C1 = "Wattage"
    Range("V2").Select
    Application.CutCopyMode = False
    Application.CutCopyMode = False
    ActiveCell.FormulaR1C1 = _
        "=VLOOKUP(RC[-13],'EO Oper Vlookups for Script (2)'!R6C5:R368C9,5,FALSE)"
    Selection.AutoFill Destination:=Range("V2:V448")
    Range("V2:V448").Select
    Range("V1").Select
    Selection.AutoFilter
    Selection.AutoFilter
    ' ActiveSheet.Range("$A$1:$V$444").AutoFilter Field:=22, Criteria1:="#N/A"
    Sheets("ADD & END Operand Mode2 Supply").Select
    Range("I1:P1").Select
    Selection.Copy
    Sheets("Installation WKG").Select
    activewindow.SmallScroll ToRight:=5
    Range("W1").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("W2").Select
    Application.CutCopyMode = False
    Application.CutCopyMode = False
    ActiveCell.FormulaR1C1 = _
        "=VLOOKUP(RC[-14],'EO Oper Vlookups for Script (2)'!R6C5:R188C9,3,FALSE)"
    Range("W2").Select
    Selection.AutoFill Destination:=Range("W2:W448")
    Range("W2:W448").Select
    Range("AA2").Select
 
Last edited by a moderator:
Upvote 0
As that is a totally different question, you will need to start a new thread. Thanks
Also when posting code please use code tags
 
Upvote 0

Forum statistics

Threads
1,215,220
Messages
6,123,698
Members
449,117
Latest member
Aaagu

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