Elseif statements - 'Application-Defined or Object-defined error' help

Sppinner

New Member
Joined
May 6, 2013
Messages
20
Hello,

Currently I am trying to use Elseif statments to copy and paste information into a target cell from another cell on the same worksheet based on the value of the target cell.

When I try to run my code, I recieve the following error message:
'Run-time error 1004: Application-based or Object-based error"

Can anybody advise me on how to change my coding to fix this issue?
Here is the coding I have created:

Sub helpMe()

Dim i As Integer
Dim j As Integer

For i = 6 To 30

For j = 4 To 18

If Cells(i, j).Value = 5 Then
Range(A43).Select.Copy
Cells(i, j).Select.Paste

ElseIf Cells(i, j).Value = 4 Then
Range(A42).Select.Copy
Cells(i, j).Select.Paste

ElseIf Cells(i, j).Value = 3 Then
Range(A41).Select.Copy
Cells(i, j).Select.Paste

ElseIf Cells(i, j).Value = 2 Then
Range(A40).Select.Copy
Cells(i, j).Select.Paste

ElseIf Cells(i, j).Value = 1 Then
Range(A39).Select.Copy
Cells(i, j).Select.Paste

Else: Cells(i, j).Value = ""

End If

Next j

Next i

End Sub

Is someone able to assist me in fixing this error or tell me of a better way to do this?

Thank you,

-Sppinner
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
Range(A43).Select.Copy

These lines need to be written as:
Code:
Range("A43").Copy

When naming a cell in the Range object, it needs to be in quotes. You also don't need the .Select
 
Last edited:
Upvote 0
Thank you for your help! It has gotten me past the run-time error 1004

Now however, I am getting "Runtime error 438: object doesn't support this property of method"

Thoughts on why this is?
 
Upvote 0

Forum statistics

Threads
1,213,532
Messages
6,114,177
Members
448,554
Latest member
Gleisner2

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