0

VBA を使用して、隣接するセルで選択された通貨に基づいてセルの数値形式を設定しようとしています。以下のサンプルを参照してください。

ここに画像の説明を入力

これまでのところ、以下のコードを使用していますが、フォーマットを正しく表示できないようです

Option Explicit
Public preValue As Variant
Private Sub Worksheet_Change(ByVal Target As Range)

Dim cell As Range
Dim Rng As Range
Dim ccy As String

ccy = Range("A3").Value
pctFormat = "0.000%"
fxFormat = ccy + " " + pctFormat


If Target.Cells.Count > 1 Then Exit Sub
On Error Resume Next
If Not Intersect(Target, Range("A2:A10")) Is Nothing Then
    If Target.Value <> preValue And Target.Value <> "" Then
        Application.EnableEvents = False

  Cells(Target.Row, Target.Column + 1).NumberFormat = fxFormat

        Application.EnableEvents = True

    End If
End If

On Error GoTo 0
End Sub
4

2 に答える 2

1

多分:

fxFormat = chr(34) & ccy & chr(34) & " " & pctFormat
于 2013-06-05T21:47:29.870 に答える