Opening worksheet in another workbook advice

ipbr21054

Well-known Member
Joined
Nov 16, 2010
Messages
5,832
Office Version
  1. 2007
Platform
  1. Windows
Hi,
Struggling with this.
I have the code in use below but it fails when i try to open the new workbook.

Do you see why please

Rich (BB code):
Private Sub CommandButton1_Click()
Application.ScreenUpdating = False
Dim c As Range
Dim ans As String
Dim Lastrow As Long
ans = ActiveCell.Value
    Workbooks.Open Filename:="C:\Users\Ian\Desktop\REMOTES ETC\DR\DR.xlsm"
    Worksheets("POSTAGE").Activate
Lastrow = Sheets("Sheet13").Cells(Rows.Count, "B").End(xlUp).Row
    For Each c In Sheets("Sheet13").Range("B1:B" & Lastrow)
        If c.Value = ans Then Application.Goto Reference:=Sheets("Sheet13").Range(c.Address): Exit Sub
    Next
Application.ScreenUpdating = True
End Sub
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
I have now sorted the issue.

CHANGE WRONG CODE
Rich (BB code):
 Workbooks.Open Filename:="C:\Users\Ian\Desktop\REMOTES ETC\DR\DR.xlsm"

CORRECT CODE
Rich (BB code):
Workbooks.Open ("C:\Users\Ian\Desktop\REMOTES ETC\DR\DR.xlsm")
 
Upvote 0

Forum statistics

Threads
1,224,818
Messages
6,181,152
Members
453,021
Latest member
Justyna P

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