|
▼mutu さん:
こんにちは。
Evaluateをとおして、ワークシート関数を使う方法もです。
新規ブックの標準モジュールに
'==============================================================
Sub main()
Dim teststr As String
With Range("a1")
.NumberFormatLocal = "@"
.Value = "123456789"
MsgBox "セルA1 = ""123456789"" 9バイト取得" & vbCrLf & _
"Evaluate(""leftb(a1,9)"") = " & _
Evaluate("leftb(a1,9)") & vbCrLf & _
"StrConv(LeftB(StrConv(.Value, vbFromUnicode), 9), vbUnicode) = " & _
StrConv(LeftB(StrConv(.Value, vbFromUnicode), 9), vbUnicode) & vbCrLf & _
"LeftB(.Value, 9) = " & LeftB(.Value, 9)
teststr = "123456789"
MsgBox "teststr = ""123456789"" 9バイト取得" & vbCrLf & _
"Evaluate(""leftb("" & teststr & "",9)"") = " & _
Evaluate("leftb(""" & teststr & """,9)") & vbCrLf & _
"StrConv(LeftB(StrConv(.Value, vbFromUnicode), 9), vbUnicode) = " _
& StrConv(LeftB(StrConv(teststr, vbFromUnicode), 9), vbUnicode) & vbCrLf & _
"LeftB(.Value, 9) = " & LeftB(teststr, 9)
End With
End Sub
確認してみてください。
|
|