Opening worksheet in another workbook advice

ipbr21054

Well-known Member
Joined
Nov 16, 2010
Messages
5,602
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

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
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,221,418
Messages
6,159,791
Members
451,589
Latest member
Harold14

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