Runtime error 424 on vba if else

exceljen86

New Member
Joined
Nov 26, 2015
Messages
15
Hi All,

I'm getting runtime error 424 Object not found on the following vba

Code:
Sub Macro2()
'
' Macro2 Macro
'


'
    If ws.input("C3") = "Y" Then
    Sheets(Array("1.02", "1.04")).Select
    
    ElseIf ws.input("C4") = "Y" Then
    Sheets(Array("1.03")).Select
    Sheets("1.04").Activate
    End If
    ActiveWorkbook.ActiveSheet.Copy
End Sub


I know the problem will be extremely simple, but I'm well out of practice and would REALLY appreciate someone's help.

Thanks in advance!!!!!!!
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
looks like ws is undefined.
failing on first line (ws.input) right?
if ws is a sheet (current active sheet?), and C3 the cell you want the value from, try Activesheet.Range("C3").Value
 
Upvote 0
probably because you're only using the copy command on the Activesheet, the current front facing sheet.

rather than use Select and then copy, just use the Copy method directly.

Make sure to use Before or After too, or else the copy will auto-generate a new workbook and paste into that, such as:

Code:
ActiveWorkbook.Worksheets(Array(1, 2)).Copy After:=Worksheets(Worksheets.Count)

worksheets.count is effectively the same as the index of hte last worksheet in the workbook, to always insert at the end.
and i'm using index numbers instead of sheet names, but you already got the array of sheet names thing down.
 
Upvote 0

Forum statistics

Threads
1,214,541
Messages
6,120,110
Members
448,945
Latest member
Vmanchoppy

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