Logo 
Search:

MS Office Answers

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds
  Question Asked By: Bastet Massri   on Jan 29 In MS Office Category.

  
Question Answered By: Angel Watkins   on Jan 29

Sorry, I forgot to alter the numerator of the division.
The calculation should read...
rlCell.Value = Application.WorksheetFunction.Round(rlCell.Value /
1000000, 2)

As for running the macro  only once then it's possible I misunderstood what
you wanted.

I thought you only wanted the procedure to run  once when the workbook was
opened. The given code  will do just that. If you run the procedure on it's
own again then of course you'll get the message  box.

If you never whant a message box  again after the procedure has run once then
as I said before, you need to set some sort of "flag" to tell the procedure
that it's already been run. Try defining a public variable and setting it
when the procedure runs.

Option Explicit
Public bgDoNotRunAgain as boolean

Sub Auto_Open
mln
bgDoNotRunAgain = True
End sub

Sub mln()

Dim llAnswer as long
Dim lsMsg as string
Dim lsTitle as string
Dim rlCell as Range

If bgDoNotRunAgain then
Exit sub
endif

lsMsg = "Please note that this will replace  formulae with value."
lsMSg = lsMsg & vbCrLf
lsMSg = lsMsg & "So you are requested  to run this on a copy
of the file."

lsTitle = "Important"

llAnswer = MsgBox(lsMsg, vbYesNo + vbExclamation, lsTitle)

If llAnswer = vbYes Then

For Each rlCell In Selection

rlCell.Value = Application.WorksheetFunction.Round(c / 1000000, 2)

Next rlCell

End If

End Sub

Share: 

 

This Question has 6 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on Messabe Box to appear once Or get search suggestion and latest updates.


Tagged: