Application.goto Runtime Error

Santaflare

New Member
Joined
Jan 4, 2017
Messages
14
Hi,

-I’m trying to construct a function that will enable auser to filter data by selecting a specific name in a pre-defined cell.

I’m using this code:


Code:
Sub Find_W2()
    Dim FindString As String
    Dim Rng As Range
    FindString = Sheets("Data").Range("I30").Value
    If Trim(FindString) <> "" Then
        With Sheets("Data").Range("D:D")
            Set Rng = .Find(What:=FindString, _
                            After:=.Cells(.Cells.Count), _
                            LookIn:=xlValues, _
                            LookAt:=xlWhole, _
                            SearchOrder:=xlByRows, _
                            SearchDirection:=xlNext, _
                            MatchCase:=False)
            If Not Rng Is Nothing Then
[COLOR=#ff0000]                Application.Goto Rng, True[/COLOR]
            Else
                MsgBox "Namn saknas"
            End If
        End With
        Worksheets("Data").Activate
        Selection.Offset(rowOffset:=0, columnOffset:=12).Activate
        Selection.Offset(0, -7).Resize(Selection.Rows.Count + 0, _
        Selection.Columns.Count + 11).Select
        Selection.Copy
        Call Phase2
    End If
End Sub



Column D is where the names are, and the columns I-T contains the actual data for each row.

When I try to run the macro I get runtime error 1004 with the message that the method ‘Goto’ in the object ‘_Application’ failed.

(The red text.)


Previously the code worked just fine, but recently this message is shown every time the macro is activated.

Any thoughts as to why, and what I might do to remedy the situation?


 
Last edited:

Some videos you may like

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop

Yongle

Well-known Member
Joined
Mar 11, 2015
Messages
6,977
Office Version
  1. 365
Platform
  1. Windows
Is the worksheet protected?
 

Santaflare

New Member
Joined
Jan 4, 2017
Messages
14
Is the worksheet protected?

No it isn't.
However, I just found the solution. The macro was linked to another one in the same module which hides the data tab. Hence the code couldn't be completed as intended.

Silly mistake..
 

Watch MrExcel Video

Forum statistics

Threads
1,123,381
Messages
5,601,302
Members
414,440
Latest member
Kim0204

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