![]() |
Open Workbook
Hi I have the following code:
If Workbooks("Analysis.xls").Worksheets("Names").Cell s(2, 3)="" Then txtPass = InputBox("Please Insert Your Login") Else txtPass = Workbooks("Analysis.xls").Worksheets("Names").Cell s(2, 3).Value End If What code should I add in order that if the Workbooks("Analysis.xls") is not opened continues the macro still runs txtPass = InputBox("Please Insert Your Login") in the next line Regards, Pedro |
Open Workbook
Pedro,
Here's one way Dim txtPass Dim oWB As Workbook On Error Resume Next Set oWB = Workbooks.Open("Analysis.xls") On Error GoTo 0 If oWB Is Nothing Then txtPass = InputBox("Please Insert Your Login") Else txtPass = oWB.Worksheets("Names").Cells(2, 3).Value End If -- HTH Bob Phillips ... looking out across Poole Harbour to the Purbecks (remove nothere from the email address if mailing direct) "Pedro" wrote in message ... Hi I have the following code: If Workbooks("Analysis.xls").Worksheets("Names").Cell s(2, 3)="" Then txtPass = InputBox("Please Insert Your Login") Else txtPass = Workbooks("Analysis.xls").Worksheets("Names").Cell s(2, 3).Value End If What code should I add in order that if the Workbooks("Analysis.xls") is not opened continues the macro still runs txtPass = InputBox("Please Insert Your Login") in the next line Regards, Pedro |
Open Workbook
On Error Resume Next
set wkbk = Workbooks("Analysis.xls") On Error goto 0 if not wkbk is nothing then If Workbooks("Analysis.xls").Worksheets("Names").Cell s(2, 3)="" Then txtPass = InputBox("Please Insert Your Login") Else txtPass = Workbooks("Analysis.xls"). _ Worksheets("Names").Cells(2,3).Value End If Else Pass = InputBox("Please Insert Your Login") End if -- Regards, Tom Ogilvy "Pedro" wrote in message ... Hi I have the following code: If Workbooks("Analysis.xls").Worksheets("Names").Cell s(2, 3)="" Then txtPass = InputBox("Please Insert Your Login") Else txtPass = Workbooks("Analysis.xls").Worksheets("Names").Cell s(2, 3).Value End If What code should I add in order that if the Workbooks("Analysis.xls") is not opened continues the macro still runs txtPass = InputBox("Please Insert Your Login") in the next line Regards, Pedro |
Open Workbook
Sorry misread it, it should be
Dim txtPass Dim oWB As Workbook On Error Resume Next Set oWB = Workbooks("Analysis.xls") On Error GoTo 0 If oWB Is Nothing Then txtPass = InputBox("Please Insert Your Login") Else txtPass = oWB.Worksheets("Names").Cells(2, 3).Value End If -- HTH Bob Phillips ... looking out across Poole Harbour to the Purbecks (remove nothere from the email address if mailing direct) "Bob Phillips" wrote in message ... Pedro, Here's one way Dim txtPass Dim oWB As Workbook On Error Resume Next Set oWB = Workbooks.Open("Analysis.xls") On Error GoTo 0 If oWB Is Nothing Then txtPass = InputBox("Please Insert Your Login") Else txtPass = oWB.Worksheets("Names").Cells(2, 3).Value End If -- HTH Bob Phillips ... looking out across Poole Harbour to the Purbecks (remove nothere from the email address if mailing direct) "Pedro" wrote in message ... Hi I have the following code: If Workbooks("Analysis.xls").Worksheets("Names").Cell s(2, 3)="" Then txtPass = InputBox("Please Insert Your Login") Else txtPass = Workbooks("Analysis.xls").Worksheets("Names").Cell s(2, 3).Value End If What code should I add in order that if the Workbooks("Analysis.xls") is not opened continues the macro still runs txtPass = InputBox("Please Insert Your Login") in the next line Regards, Pedro |
All times are GMT +1. The time now is 10:02 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com