ElseIf Run-time error '1004'

BiscuitButter

New Member
Joined
Feb 28, 2020
Messages
2
Office Version
  1. 365
Platform
  1. Windows
Hello,

This is my first time requesting help for any form of coding so I deeply apologize in advance for any faux pas that I'm about to commit.
That being said...

I'm trying to copy certain ranges from one worksheet to another. Reason being, the source sheet contains a bunch of confidential info that my customers aren't supposed to be privy to.

My problem is occurring with my ElseIf argument. I need to select one of two columns based on whether I'm generating a form for Spring/Summer goods or Fall/Winter. When I input 'SS', everything works fine. When I input 'FW', I get a Run-time 1004 error. If I put in anything other than 'FW', I get my "Your an idiot" response.

What did I do wrong?

VBA Code:
Private Sub formulae()

Dim ws_casi As Worksheet
Dim ws_data As Worksheet
Dim LastRow_casi As Long
Dim LastRow_data As Long

Set ws_casi = ThisWorkbook.Worksheets("Cut And Sold Inquiry")
Set ws_data = ThisWorkbook.Worksheets("DATA")

LastRow_casi = ws_casi.Cells.Find("*", searchorder:=xlByRows, searchdirection:=xlPrevious).Row
LastRow_data = ws_data.Cells.Find("*", searchorder:=xlByRows, searchdirection:=xlPrevious).Row

season = UCase(Application.InputBox(prompt:="What Season Is This ATS For?" & vbCrLf & "Enter 'SS' for 'Spring/Summer'" & vbCrLf & "Enter 'FW' for 'Fall/Winter'", Type:=2))

' DATA WS formulas
ws_data.Range("E2:E" & LastRow_data).Formula = "=B2&C2&D2"
ws_data.Range("F2:F" & LastRow_data).Formula = "=IF(LEN(D2)>0,B2&""-""&C2&""-""&D2,IF(LEN(C2)>0,B2&""-""&C2,C2))"
ws_data.Range("J2:J" & LastRow_data).Formula = "=IF(ISNUMBER(RIGHT('Cut And Sold Inquiry'!$O2,1)+0),LEFT('Cut And Sold Inquiry'!$O2,1),'Cut And Sold Inquiry'!$O2)"
ws_data.Range("O2:O" & LastRow_data).Formula = "=RIGHT('Cut And Sold Inquiry'!$U2,LEN('Cut And Sold Inquiry'!$U2)-6)"

If season = "SS" Then
        ws_casi.Range("V2:V" & LastRow_casi).Copy Destination:=ThisWorkbook.Worksheets("DATA").Range("P2")
    ElseIf season = "FW" Then
        ws_casi.Range("W2:2" & LastRow_casi).Copy Destination:=ThisWorkbook.Worksheets("DATA").Range("P2")
    Else
        MsgBox "I just wanted you to type SS or FW." & vbCrLf & "Was it really that hard?"
End If

End Sub
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
In this line:
ws_casi.Range("W2:2" & LastRow_casi).Copy Destination:=ThisWorkbook.Worksheets("DATA").Range("P2")

It should be "W2:W"
 
Upvote 0
Change the 2nd "2" in this line to a "W"
VBA Code:
ws_casi.Range("W2:2" & LastRow_casi).Copy Destination:=ThisWorkbook.Worksheets("DATA").Range("P2")
VBA Code:
 ws_casi.Range("W2:W" & LastRow_casi).Copy Destination:=ThisWorkbook.Worksheets("DATA").Range("P2")
 
Upvote 0

Forum statistics

Threads
1,213,546
Messages
6,114,256
Members
448,558
Latest member
aivin

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