0
ドルの通貨書式設定を行った。それはうまく動作します。私はユーロ、ポンドのような他の通貨に対しても同じ通貨フォーマットをしたいと思います。 以下は私が試したコードです。 Plsヘルプ。通貨VBAを使用したユーロの書式設定
コード:
Sub CurrencyFormat_UK()
'
' Currency formating
'
Dim oCl As Word.Cell
Dim oRng As Range
'
' Condition to check the selected data
'
If Selection.Type = wdSelectionIP Or _
Not Selection.Information(wdWithInTable) Then
MsgBox "Select a cell or range of cells before running" _
& " this macro.", , "Nothing Selected"
Exit Sub
End If
For Each oCl In Selection.Cells
Set oRng = oCl.Range
'
'Drop of the end of cell mark
'
oRng.End = oRng.End - 1
With oRng
If IsNumeric(oRng) Then
.Text = FormatCurrency(Expression:=.Text, NumDigitsAfterDecimal:=2, _
IncludeLeadingDigit:=vbTrue, UseParensForNegativeNumbers:=vbTrue)
End If
If oRng.Characters.count = 1 Then GoTo Skip
On Error GoTo Skip
'Catch errors here
If InStr(oRng.Text, "€") = False Then
oRng.Font.Color = wdColorRed
oRng.Select
MsgBox "Cell content is not numerical.", , "Error"
Selection.Collapse wdCollapseEnd
End If
Skip:
End With
Next oCl
lbl_Exit:
Exit Sub
End Sub
をそれはどのようなエラーですか?私はあなたが何がうまくいかないと言っていないなら、どうすれば私たちを助けることができますか? – CyberClaw
実際に "FormatCurrency"関数は、ドル形式のコード形式で自動的に使用されます。他の通貨でもフォーマットできる他の方法はありますか? –
誰かにあなたのために仕事をさせたい場合は、プログラマーに支払う必要があります。このウェブサイトは、あなたが持っている可能性のある疑いや誤りを助けてくれるプログラマーのためのものです。「私のためにすべてをしてください、ktkxbai! – CyberClaw