• ベストアンサー
※ ChatGPTを利用し、要約された質問です(原文:「'」もascで変換させたい)

「'」もascで変換させたい

YanenoSuzumeの回答

回答No.1

A1が test (シングルクォーテーションを含まず、半角4文字) を表しているためです。 A1 に test と入力しても 'test と入力しても同じです。 'test (シングルクォーテーションを含む、半角5文字) は ="'test" とすれば入力できました。

ogbubysr
質問者

お礼

ありがとうございました。

関連するQ&A

  • Chr関数であいうえお順に

    Chr関数であいうえお順に文字をエクセルに書き出そうとしたけど、 単純にはいかないのですかね? Sub test() Dim MyRow As Long Dim i As Long For MyRow = 1 To 51 Cells(MyRow, 1) = Chr(-32096 + i) i = i + 2 Next MyRow End Sub これを実行すると、濁点が入ったりするのですが、 綺麗に「あ~ん」まで取得する方法はありますか? 複雑なコードを作るしかないのですかね?

  • 日本語(ひらがな・カタカナ・漢字)があるか判断する

    日本語(ひらがな・カタカナ・漢字)があるか判断する方法 Sub test1() Dim Str As String Dim MidStr As String Dim i As Long Str = "aiu123あいう" For i = 1 To Len(Str) MidStr = Mid(Str, i, 1) If Asc(MidStr) < 0 Then MsgBox "日本が混ざっています" Exit Sub End If Next End Sub このマクロを実行すると、「あ」の順番になった時にうまく反応するのですが、 いまいちASC関数についてよくわからないので教えてください。 ASC関数でマイナスになるものは全て日本語なのでしょうか? Asc(MidStr) < 0でいいのか、そこが知りたいです。 a→97 i→105 u→117 1→49 2→50 3→51 あ→-32096 い→-32094 う→-32092 でした。 ご回答よろしくお願いします。

  • 文字コードに対応する文字が振られていないの?

    windows7を使っています。 エクセルVBAで Sub Sample1() Dim i As Long Dim myRow As Long For i = -32768 To 32767 myRow = myRow + 1 Cells(myRow, 1) = Chr(i) Next i End Sub のコードで文字コードをすべて書き出してみたのですが 空白や「」だけ等がいくつもあります。 これはどうしてでしょうか? 文字コードに対応する文字が振られていないのでしょうか? -32768 To 32767の理由は Asc 関数のヘルプを見たら 「DBCS を使用しているシステムでは、 -32768 ~ 32767 の範囲の値が返されます。」 となっていた為です。

  • 質問No.2259731で教えて頂いたコードを訳して欲しい

    昨日質問し、回答を頂いたものです。 もう少しで作業が上手くいきそうなのですが 教えて頂いたコードの各工程の意味(処理)がわからず 止まっています。 一つずつ調べてはいますが、かなり時間がかかっていて とても今日中に終わりそうになくて焦っています。 急いでいるもので、すいませんがどなたか下のコードの各行が どのような意味か、訳をつけて頂けないでしょうか。 Sub Test() Dim myCol As Integer, myVal Dim LRow As Long, myRow As Long With ActiveSheet  LRow = .Cells(65536, 1).End(xlUp).Offset(1, 0).Row  For myCol = .Range("IV1").End(xlToLeft).Column To 3 Step -1    myVal = 0    myRow = .Cells(65536, myCol).End(xlUp).Row    If myRow = 1 Then     .Columns(myCol).Delete    Else     Do While myRow > 1 And .Cells(myRow, myCol).Value <> "●"       myVal = myVal + .Cells(myRow, myCol).Value       myRow = myRow - 1     Loop     .Cells(LRow, myCol) = myVal    End If  Next myCol End With End Sub ちなみに元の質問内容は http://oshiete1.goo.ne.jp/kotaeru.php3?q=2259731 です。

  • プロシージャー名を変数にはできない?

    シートに test1 test2 test3 として、 -------------------------------- Sub Sample() Dim myRow As Long Dim procedure As String For myRow = 1 To Cells(Rows.Count, "A").End(xlUp).Row procedure = Cells(myRow, 1) Call procedure Next myRow End Sub Sub test1() End Sub Sub test2() End Sub Sub test3() End Sub -------------------------------- こういう事ってできないのでしょうか? シートの文字を読み取ってプロシージャーを実行できれば、順番変えたり、要らないプロシージャーを消したりを、シート上で管理できるから楽なのになと思ったのですが。 これをやろうとすると、procedureというプロシージャーがないから Sub、Function、または Property が必要です。 になってしまいます。

  • VBA 時間の抜き出しが上手く処理できない

    時間の抜き出しをするのに下記のコードを候補に挙げましたが、 「'コロンが2個の場合 (時:分:秒)」の場合は上手く処理できますが 「'コロンが1個の場合 (分:秒)」の数値が上手く処理できません。 ’----------------------------------------------------------------------- Option Explicit Sub コロンの数を数える() Dim i As Long, cnt As Long, n As Variant For i = 2 To Cells(Rows.Count, "A").End(xlUp).Row cnt = 0 '←cntをリセット Do n = InStr(n + 1, Cells(i, "A"), ":") If n = 0 Then Exit Do Else cnt = cnt + 1 End If Loop If cnt < 1 Then MsgBox "[:]がありません。" '←cntが1未満のときにメッセージを発出します。 End Else Cells(i, "B").Value = cnt End If Next End Sub Sub 時間抜き出し() Dim i As Long, cnt As Long Dim n As Single For i = 2 To Cells(Rows.Count, "A").End(xlUp).Row n = InStr(n + 1, Cells(i, "A"), ":") 'コロン「:」の位置を特定する If Cells(i, "B") = 1 Then 'コロンが1個の場合 (分:秒) Cells(i, "C").NumberFormatLocal = "h:mm:ss" If Mid(Cells(i, "A"), n - 2, 1) = " " Or Mid(Cells(i, "A"), n - 2, 1) = "(" Then '10分以下の場合 Cells(i, "C") = Mid(Cells(i, "A"), n - 1, 4) Cells(i, "C") = "0:" & Cells(i, "C") Else '10分以上 Cells(i, "C") = Mid(Cells(i, "A"), n - 2, 5) Cells(i, "C") = "0:" & Cells(i, "C") End If Else 'コロンが2個の場合 (時:分:秒) Cells(i, "C").NumberFormatLocal = "h:mm:ss" Cells(i, "c") = Mid(Cells(i, "A"), n - 1, 7) End If n = 0 Next End Sub

  • 【VBA】セルの中身を日付形式に変換したい

    w列のセルの中に20140701のように入っているセルを2014/07/01に変換するマクロを作っております。 それで以下のように書いてみたのですが、「型が一致しません」と出てしまい、先に進めずにおります…。お力借りられますと幸いです。 Dim org As String Dim buf As String Dim i As Long i = 1 Do Until Cells("w", i) = "" Cells("w", i).Select With ActiveCell org = .Value If Len(org) = 8 Then buf = _ Mid(org, 1, 4) & "/" & _ Mid(org, 5, 2) & "/" & _ Mid(org, 7, 2) If IsDate(buf) = True Then .Value = buf .NumberFormatLocal = "yyyy年m月d日" End If End If End With i = i + 1 Loop

  • EXCEL VBAの配列でわかりません。

    こんなコードがあるのですが、最後の他のシート(作業中シート)に書き込もうとするとエラーになってしまいます。”Sheets("作業中").”を抜くと同じシートに結果は返ってくるのですが…。コードの内容は、ある範囲のある列から空白ではないセルを探し出してその行のデータを配列で汲み取り、他のシートに一括で洗い出すというものです。 Sub 作業中() Dim myRow As Long Dim Data As Variant Dim WC() As Variant Dim WCE() As Variant myRow = Range("H1").CurrentRegion.Rows.Count Data = Range("H1:M" & myRow).Value For i = 1 To myRow If Data(i, 5) <> "" Then a = a + 1 Else b = b + 1 End If Next ReDim WC(a) ReDim WCE(b) c = 0 d = 0 For i = 1 To myRow If Data(i, 5) <> "" Then WC(c) = Range("H" & i & ":K" & i).Value c = c + 1 Else WCE(d) = Range(Cells(i, 8), Cells(i, 11)).Value d = d + 1 End If Next For i = 0 To a Range(Cells(i + 1, 15), Cells(i + 1, 18)).Value = WC(i) Next For i = 0 To b Range(Cells(i + 1, 19), Cells(i + 1, 22)).Value = WCE(i) Next e = Range(Cells(1, 15), Cells(a, 18)).Value Sheets("作業中").Range(Cells(1, 1), Cells(a, 4)).Value = e End Sub ちなみに同じシートから↓のコードを実行するとうまくいきます。 なぜ~??わからな~い??おしえてくださーい!! Sub test() Dim a As Variant a = Range("H1:K4") Sheets("作業中").Range("N1:Q4") = a End Sub

  • 文字列をバイト数に変換して、設定数よりオーバーしたセルを赤文字にしたい

    文字列をバイト数に変換して、設定数よりオーバーしたセルを赤文字にしたいと思い、下記のマクロを組みました。 しかし、VBAのLen関数は半角も2バイトで計算するとテキスト本に書いているのを読んだのですが、全角は2バイト、半角は1バイトで計算する方法はありますでしょうか? どなたか教えていただけますと大変助かります。 OSはXP、Excelは2003 を使用しています。 Sub 文字数を調べて色を変える() Dim mojicnt As Integer Dim moji As String Dim maxgyo As Long Dim motogyo As Long maxgyo = Cells(Rows.Count, 1).End(xlUp).Row For motogyo = 2 To maxgyo moji = Cells(motogyo, 2).Value mojicnt = LenB(moji) If mojicnt > 32 Then Cells(motogyo, 2).Font.ColorIndex = 3 End If Next motogyo For motogyo = 2 To maxgyo moji = Cells(motogyo, 4).Value mojicnt = LenB(moji) If mojicnt > 50 Then Cells(motogyo, 4).Font.ColorIndex = 3 End If Next motogyo For motogyo = 2 To maxgyo moji = Cells(motogyo, 5).Value mojicnt = LenB(moji) If mojicnt > 50 Then Cells(motogyo, 5).Font.ColorIndex = 3 End If Next motogyo For motogyo = 2 To maxgyo moji = Cells(motogyo, 8).Value mojicnt = LenB(moji) If mojicnt > 56 Then Cells(motogyo, 8).Font.ColorIndex = 3 End If Next motogyo End Sub 説明不足のところがありましたら、申し訳ありません。 よろしくお願い致します。

  • 文字列を分割して、分割した文字の一番右側を表示するにはどうしたら良いのでしょうか?

    Sub test2() Dim moji() As String Dim a As Range Dim 行 As Long For 行 = 2 To Cells(Rows.Count, 1).End(xlUp).Row Set a = Cells(行, 1) moji() = Split(a, "-") On Error GoTo moji Cells(行, 2) = moji(3) Next 行 moji: Cells(行, 2) = moji(2) End Sub で A列 B列 1-2-3-4 4 10-11-11-12 12 1-2-3-10 10 1-2-10-3 3 1-2-3 3 1-2 1-13 11-14 11-3 の結果になりますが1-2,11-14,11-3の部分が表示できません。 どなたかよいほうほうをお願いします。