Code is choking. Any help?

fabriciofcmiranda

Board Regular
Joined
Jun 27, 2006
Messages
62
Does anyone know why this code isn't working?

Code:
Sub InsertRowNumber()
    Dim rng As Range
    On Error Resume Next
    Set rng = Application.InputBox(prompt:="Select the code of the invoice.", _
    Title:="Code", Default:=Selection.Address, Type:=8)
    On Error GoTo 0
    If Not rng Is Nothing Then
      If Not rng.Address = ActiveCell.Address Then rng.Copy
    Else
      Exit Sub
    End If
    Sheets("Report").Select
    Range("report_condigoentrada").Select
    ActiveSheet.Paste    
    Selection.EntireRow.Hidden = False
    Application.CutCopyMode = False
    Range("report_inicio").Select
End Sub

The code is choking on "Range("report_condigoentrada").Select". I'd appreciate if someone could help me with this one.
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
I'm assuming that by "choking" you mean that that statement causes an error? What is the error?

Does a range named "report_condigoentrada" exist? If it does, is it on that page?

Incidentally, you don't have to select a range in order to paste to it:
Code:
If Not rng.Address = ActiveCell.Address Then rng.Copy     Destination:=Sheets("Report").Range("report_condigoentrada")
 
Upvote 0
You're right, Von Pookie. I mistyped the "report_condigoentrada" on the code (the correct is "report_codigoentrada"). That was the problem.
Your post was also very helpful to simplify my code.
Thank you so much for your help and attention (as always).
Best regards,
FM
 
Upvote 0

Forum statistics

Threads
1,214,648
Messages
6,120,726
Members
448,987
Latest member
marion_davis

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