ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   macro was working, now it's not working (https://www.excelbanter.com/excel-programming/300846-macro-working-now-its-not-working.html)

RichardO[_11_]

macro was working, now it's not working
 
Hello all:

I have the following macro which on clicking YES, would run th
formatsummary which does some things to the "Summary" worksheet. The
it adds 1 workday to cell B4 of the "Summary" worksheet.

When I run the macro, I am getting a compiler error with (.Rang
highlighted in yellow.

Before I added the:

If MsgBox("Click Yes to refresh workbook", vbYesNo) = vbYess Then
...
End If

The macro worked okay, now it's not working fine.

Thanks for helping.



Private Sub Workbook_Open()
If MsgBox("Click Yes to refresh workbook", vbYesNo) = vbYess Then
formatsummary
With Worksheets("Summary").[b4] = workday(.Range("B4"), 1)
End With
End If
End Su

--
Message posted from http://www.ExcelForum.com


William[_2_]

macro was working, now it's not working
 
Hi Richard

Should "vbYess" be "vbYes"?
--
XL2002
Regards

William



"RichardO " wrote in message
...
| Hello all:
|
| I have the following macro which on clicking YES, would run the
| formatsummary which does some things to the "Summary" worksheet. Then
| it adds 1 workday to cell B4 of the "Summary" worksheet.
|
| When I run the macro, I am getting a compiler error with (.Range
| highlighted in yellow.
|
| Before I added the:
|
| If MsgBox("Click Yes to refresh workbook", vbYesNo) = vbYess Then
| ..
| End If
|
| The macro worked okay, now it's not working fine.
|
| Thanks for helping.
|
|
|
| Private Sub Workbook_Open()
| If MsgBox("Click Yes to refresh workbook", vbYesNo) = vbYess Then
| formatsummary
| With Worksheets("Summary").[b4] = workday(.Range("B4"), 1)
| End With
| End If
| End Sub
|
|
| ---
| Message posted from
http://www.ExcelForum.com/
|



RichardO[_12_]

macro was working, now it's not working
 
You're right, I changed the Yess to Yes,

The formatsummary macro is running okay, but then I got a debug erro
when the code got to:


With Worksheets("Summary")
.[b4] = workday(.Range("B4"), 1)
End With

the .Range is highlighted in blue, while the name of the function:

Private Sub Workbook_Open() is highlighted in yellow.

Can you tell what's happening. Again, when I didn't have the If
statement below the code ran okay:

MsgBox("Click Yes to refresh workbook", vbYesNo) = vbYes Then
. ..
End If


Thanks agai

--
Message posted from http://www.ExcelForum.com



All times are GMT +1. The time now is 05:44 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com