[ 初めての方へ | 一覧(最新更新順) | 全文検索 | 過去ログ ]
『アルファベットのみ削除したいのですが 』(わからず)
いつも参考にさせていただいています。つまずいた(わからない)個所ありますので
良いアドバイスお願いします。
セルにA1-A10とある場合表記をA1-10と10の前のアルファベットを削除したい場合どうしたら
良いでしょうか?
セルにはABC1-ABC10等もありこの表記もABC1-10とさせたいです。
どなたか良いアドバイスお願いしますm(_ _)m
>A1-A10とある場合表記をA1-10 -? → - に「置換」
>セルにはABC1-ABC10等もありこの表記もABC1-10 -??? → - に「置換」
(INA)
数式で削除するものでは、当該セルがA1だとしますと、 =IF(COUNTIF(A1,"*-*"), LEFT(A1,FIND("-",A1))&LOOKUP(99^9,--RIGHT(A1,COLUMN(1:1))),"") というものは、どうでしょう? (LOOKUP)
マクロの記録で作成しました。 (LOOKUP) Sub Macro1() Dim MAE As String Dim ATO As String Dim R As Range Dim I As Integer For Each R In Selection If Application.CountIf(R, "*-*") = 0 Then Exit For I = Application.Find("-", R.Value) MAE = Left(R.Value, I) ATO = Application.Substitute(R.Value, MAE, "", 1) ATO = Application.Substitute(ATO, "A", "") ATO = Application.Substitute(ATO, "B", "") ATO = Application.Substitute(ATO, "C", "") ATO = Application.Substitute(ATO, "D", "") ATO = Application.Substitute(ATO, "E", "") ATO = Application.Substitute(ATO, "F", "") ATO = Application.Substitute(ATO, "G", "") ATO = Application.Substitute(ATO, "H", "") ATO = Application.Substitute(ATO, "I", "") ATO = Application.Substitute(ATO, "J", "") ATO = Application.Substitute(ATO, "K", "") ATO = Application.Substitute(ATO, "L", "") ATO = Application.Substitute(ATO, "M", "") ATO = Application.Substitute(ATO, "N", "") ATO = Application.Substitute(ATO, "O", "") ATO = Application.Substitute(ATO, "P", "") ATO = Application.Substitute(ATO, "Q", "") ATO = Application.Substitute(ATO, "R", "") ATO = Application.Substitute(ATO, "S", "") ATO = Application.Substitute(ATO, "T", "") ATO = Application.Substitute(ATO, "U", "") ATO = Application.Substitute(ATO, "V", "") ATO = Application.Substitute(ATO, "W", "") ATO = Application.Substitute(ATO, "X", "") ATO = Application.Substitute(ATO, "Y", "") ATO = Application.Substitute(ATO, "Z", "") R.Value = MAE & ATO Next R End Sub
-のところで区切るのでは、ないのですね。これは、どうでしょう? (LOOKUP) Sub Macro1() Dim MAE As String Dim ATO As String Dim R As Range Dim I As Integer For Each R In Selection If Len(R.Value) = 0 Then GoTo MUSI I = 1 Do Until Asc(Mid(R.Value, I, 1)) > 90 _ Or Asc(Mid(R.Value, I, 1)) < 65 _ Or I = Len(R.Value) I = I + 1 Loop MAE = Left(R.Value, I) ATO = Application.Substitute(R.Value, MAE, "", 1) ATO = Application.Substitute(ATO, "A", "") ATO = Application.Substitute(ATO, "B", "") ATO = Application.Substitute(ATO, "C", "") ATO = Application.Substitute(ATO, "D", "") ATO = Application.Substitute(ATO, "E", "") ATO = Application.Substitute(ATO, "F", "") ATO = Application.Substitute(ATO, "G", "") ATO = Application.Substitute(ATO, "H", "") ATO = Application.Substitute(ATO, "I", "") ATO = Application.Substitute(ATO, "J", "") ATO = Application.Substitute(ATO, "K", "") ATO = Application.Substitute(ATO, "L", "") ATO = Application.Substitute(ATO, "M", "") ATO = Application.Substitute(ATO, "N", "") ATO = Application.Substitute(ATO, "O", "") ATO = Application.Substitute(ATO, "P", "") ATO = Application.Substitute(ATO, "Q", "") ATO = Application.Substitute(ATO, "R", "") ATO = Application.Substitute(ATO, "S", "") ATO = Application.Substitute(ATO, "T", "") ATO = Application.Substitute(ATO, "U", "") ATO = Application.Substitute(ATO, "V", "") ATO = Application.Substitute(ATO, "W", "") ATO = Application.Substitute(ATO, "X", "") ATO = Application.Substitute(ATO, "Y", "") ATO = Application.Substitute(ATO, "Z", "") R.Value = MAE & ATO MUSI: Next R End Sub
最後まで、ご希望が判らなかったです。 もしも、ご質問が、下のように共通の英字を最初だけ表示させることでしたら、 英字が10文字以内としまして、配列数式ですが、
=IF(LEN(A1)>1,LEFT(A1,MATCH(1,MID(A1,ROW($2:$10),1)^0,)) &SUBSTITUTE(A1,LEFT(A1,MATCH(1,MID(A1,ROW($2:$10),1)^0,)),),"") として、Ctrl+Shift+Enter。でも変換できると思います。 (LOOKUP)
A B 1 ABC5-10,ABC12,ABC13-ABC17,ABC21 ABC5-10,12,13-17,21 2 LM23,LM25,LM27-LM29,LM31 LM23,25,27-29,31
[ 一覧(最新更新順) ]
YukiWiki 1.6.7 Copyright (C) 2000,2001 by Hiroshi Yuki.
Modified by kazu.