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
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