WebFeb 24, 2015 · try to add MsgBox ws2.Range ("J1") just before Set wb1 = Workbooks (ws2.Range ("J1")). Does it give you correct workbook name? Also try Set wb1 = GetObject (ws2.Range ("J1")) – Dmitry Pavliv Mar 19, 2014 at 18:38 1 I used your code, and added .Value after the Cell name and it worked :). WebDec 27, 2024 · Set wb = Workbooks.Open (fileNameAndPath) Set sht = wb.Worksheets ("Report") ' Do action with open workbook and worksheet. MsgBox sht.Range ("A1") 'Close workbook after action is finished. wb.Close 'Clear memory Set wb = Nothing Set sht = Nothing Application.ScreenUpdating = True Application.DisplayAlerts = True End Sub …
Insert the current Excel file name, path, or worksheet in a cell
WebAug 24, 2011 · Dim wkb As Workbook Set wkb = Workbooks.Open("W:\anypath\anyfile.xls") Upvote 0. L. lokiluke ... Code: Workbooks.Open Filename:="C:\some folder\some workbook.xls" ... (that saves all sheets from an excel workbook to CSV) into a looping VBA program (just have myself … WebOct 21, 2024 · Sub Test () Dim wb As Workbook Dim ws As Worksheet Dim FilePath As String FilePath = "C:\" & AnotherVariable & ".xlsx" Set wb = Workbooks (FilePath) Set ws = Sheets ("Sheet1") wb.Activate ws.Select End Sub. Thanks for the reply, but I don't know … christian psychology today
How to do a "Save As" in vba code, saving my current Excel workbook ...
WebTo save a workbook with a new name, in the same directory, you can imply use this: ActiveWorkbook.SaveAs "new" where “new” is the new file name. To save a workbook in a new directory with a specific file extension, simply specify the new directory and file name: ActiveWorkbook.SaveAs "C:\Users\StevePC2\Downloads\new.xlsm" Other Workbook … WebAug 20, 2015 · 1 Set the other workbook first then set sheet = otherworkbook.sheetyouwant – findwindow Aug 20, 2015 at 19:35 Do you have an example of that? I've tried to use Dim wb As Workbook and then setting the workbook but it throws the same error. – Fabrizio Martinez Aug 20, 2015 at 19:42 Add a comment 1 Answer … WebMay 25, 2024 · Are you sure your file is named "file.xlsx" – John Muggins May 25, 2024 at 16:50 1 I added in the Workbooks.Open Filename:="string" and the Set wb = ActiveWorkbook, and it worked. So I then replaced the string and tested Workbooks.Open Filename:=myFile, and that worked. georgia spa hickinbotham