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

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result

Von Pookie

MrExcel MVP
Joined
Feb 17, 2002
Messages
13,686
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")
 

fabriciofcmiranda

Board Regular
Joined
Jun 27, 2006
Messages
62
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
 

Forum statistics

Threads
1,136,261
Messages
5,674,704
Members
419,520
Latest member
Jennifer4Dillon

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
Top