You have to Dim ( which is kinda like Declaring ) what each string,
range, variant is.
1st Example would read something like:
Dim ans As Integer
ans = MsgBox("Is your name " & Application.UserName & "?", vbYesNo)
If ans = vbNo Then
MsgBox ("Oh, never mind.")
MsgBox ("I must be clairvoyant!")
2nd example will replace any formulas in cells within the range you
specify with their actual values.
Again, we Dim what it is we are pointing to eg, the objects and ranges.
Dim mySht As Worksheet
Dim myFormulaRange As Range, fCell As Range
Dim answer As Integer
Set mySht = Sheets("Sheet1") '?hange name to your sheet name.
Set myFormulaRange = mySht.Range("A1:A2") '?hange range to suit.
answer = MsgBox("Convert formulas to values?", vbYesNo)
If answer <> vbYes Then Exit Sub
For Each fCell In myFormulaRange
If fCell <> "" Then
.Value = fCell
Now, my terminology I use may not be 100% accurate, but hopefully it
will point you in the right direction.
One of the many Guru's will no doubt correct any ambiguous terminology
mistakes I have made....