advanced help
per page, with , order by , clip by
Results of 1 - 1 of about 37684 for IF (0.007 sec.)
[[20081207220415]]
#score: 1591
@digest: 80b1ab02f32f5b7f4dc48cf29dbb69d9
@id: 41198
@mdate: 2008-12-11T10:23:02Z
@size: 12484
@type: text/plain
#keywords: 量表 (82347), mylimit (77610), mylimt (53346), ドマ (40471), 記漏 (38632), dump (37733), room (29768), mylist (26064), ッソ (20145), textbox (14107), 表") (10750), myindex (9315), 転送 (8818), controls (7020), the (6862), xlwhole (5350), 表" (5306), textbox2 (5282), 数量 (5142), xlnext (4771), msg (4466), commandbutton1 (4350), は転 (4295), マン (3867), ソッ (3835), a12 (2954), ッド (2900), ン) (2647), メソ (2633), メッ (2629), seiya (2590), msgbox (2448)
『ユーザーフォームのTextBoxの値をセルに入力。なんですが・・・』(メソッドマン)
Excel2003 WindowsXP Sheets"数量表"があります。 ボタンでユーザーフォームを表示させてTextBox1に入力した値を、Sheets"数量表"の A4:A12の範囲内の最後に値が入力されているセルの下のセルに入力したいのです。 調べながらも別で使用している下記コードを加工したらよいのかなとは思うのですが、どのように加工したらよいのかが解りませんでした。 Private Sub CommandButton1_Click() Dim lRow As Long With Worksheets("数量表") lRow = .Range("A" & Rows.Count).End(xlUp).Row .Range("A" & lRow + 1).Value = TextBox1.Value End With Unload Me End Sub 上記コードでしたら、A列に入力されているセルの次のセルにTextBox1の値を入力するやり方で使用しているので、『.Range(〜』の部分ではあるのかなと思うのですが。 解り難い書き方で申し訳ありません。 宜しくお願い申し上げます。 ---- Private Sub CommandButton1_Click() Dim rng As Range With Worksheets("数量表").Range("a4:a12") If .Range("a" & .Rows.Count).Value <> "" Then MsgBox "入力がエリアがいっぱいになりました" Else Set rng = .Range("a" & .Rows.Count).End(xlUp) If rng.Row >= 4 Then Set rng = rng.Range("a2") Else Set rng = .Range("a1") End If rng.Value = TextBox1.Text End If End With End Sub ichinose ---- > Sheets"数量表"の A4:A12の範囲内の最後に値が入力されているセルの下のセルに入力したいのです Private Sub CommandButton1_Click() Dim r As Range With Worksheets("数量表").Range("a4:a12") Set r = .Find("",,,xlWhole) If r Is Nothing Then MsgBox "No room to dump the data" Else r.Value = Me.TextBox1.Value End If End With End Sub (seiya) ---- ichinose様、seiya様ありがとうございました。 お二人のコードで思うように動作しました。 TextBoxが大量にある為、その都度それの中身をいじるのでいじり箇所が少なくて済むseiya様のコードを仕様させていただきます。 引き続き教えて頂きたいです。 TextBoxが9つあり、CommandButton1を押すと入力の動作なんですが、頂いたコードをTextBox番号を変えて全て記入しました。 下記のような感じでよろしいでしょうか? それとも簡素化できるのでしょうか? Private Sub CommandButton1_Click() Dim r As Range With Worksheets("数量表").Range("A3:A12") Set r = .Find("", , , xlWhole) If r Is Nothing Then MsgBox "No room to dump the data" Else r.Value = Me.TextBox2.Value End If Set r = .Find("", , , xlWhole) If r Is Nothing Then MsgBox "No room to dump the data" Else r.Value = Me.TextBox7.Value End If Set r = .Find("", , , xlWhole) If r Is Nothing Then MsgBox "No room to dump the data" Else r.Value = Me.TextBox9.Value End If Set r = .Find("", , , xlWhole) If r Is Nothing Then MsgBox "No room to dump the data" Else r.Value = Me.TextBox5.Value End If Set r = .Find("", , , xlWhole) If r Is Nothing Then MsgBox "No room to dump the data" Else r.Value = Me.TextBox11.Value End If Set r = .Find("", , , xlWhole) If r Is Nothing Then MsgBox "No room to dump the data" Else r.Value = Me.TextBox13.Value End If Set r = .Find("", , , xlWhole) If r Is Nothing Then MsgBox "No room to dump the data" Else r.Value = Me.TextBox15.Value End If Set r = .Find("", , , xlWhole) If r Is Nothing Then MsgBox "No room to dump the data" Else r.Value = Me.TextBox17.Value End If Set r = .Find("", , , xlWhole) If r Is Nothing Then MsgBox "No room to dump the data" Else r.Value = Me.TextBox19.Value End If End With End Sub ---- A4:A12 で 9このTextBox ということは 「A4:A12 が一つでも埋まっていたら転送しない」 ということですか? Private Sub CommandButton1_Click() Dim i As Long, myIndex With Worksheets("数量表").Range("a4:a12") x = Application.CountBlank(.Cells) If x <> .Cells.Count Then MsgBox "転送できません。" Exit Sub End If myIndex = [{2,7,9,5,11,13,15,17,19}] For i = 1 To 9 .Cells(i).Value = Me.Controls("TextBox" & myIndex(i)).Value Next End With End Sub (seiya) ---- seiya様こんばんわ。 遅くにすいません。 9つのTextBoxには2→7→9→〜の順番にタブオーダーを設定してまして、そこにコードを順番に入力していきます。 9つ全部TextBoxが埋まってても転送、9つではなくても1つでも2つでもTextBoxが埋まってたら転送。 とゆーような感じです。(メソッドマン) ---- ということは A4:A12のセルに2→7→9→〜の順番を当てはめてTextBoxに入力された分だけ 転送する、ということですか? (seiya) ---- おはようございます。 作業上では複数人が使用するのでたとえば、 AさんがTextBox2と7を入力してボタンを押してセルA4とA5に値が転送されました。そこで一旦ファイルは保存して閉じられ、次にBさんがまた使用する時にユーザーフォームを呼び出しTextBox2と7と9とに入力後ボタンを押したらセルA6からA8に転送されるという動作です。 セル範囲がすべて埋まると"転送できません"とメッセージがでる。 わかりにくい説明であれば大変申し訳ありません。 (メソッドマン) ---- こんな感じでしょうか? Private Sub CommandButton1_Click() Dim r As Range, myList, i As Long, n As Long Dim msg As String, myLimit As Long With Worksheets("数量表").Range("a4:a12") Set r = .Find("",.Cells(.Cells.Count) , , , , xlNext) If r Is Nothing Then MsgBox "No room to dump the data" Exit Sub End If n = r.Row : myLimt = .Rows.Count + .Row - 1 End With myList = [{2,7,9,5,11,13,15,17,19}] For i = 1 To UBound(myList) If Me.Controls("TextBox" & myList(i)).Value <> "" Then '<- 修正 11:16 & 12:34 If n > myLimit Then msg = msg & vbLf & "TextBox" & myList(i) Else Worksheets("数量表").Cells(n, "a").Value = _ Me.Controls("TextBox" & myList(i)).Value n = n + 1 End If End If Next If Len(msg) Then MsgBox "以下の" & UBound(Split(msg, vbLf)) & _ "件は 転記漏れです。" & msg End If End Sub (seiya) ---- 今試させて頂いたんですがEnd Withに対するWithがありませんとでました。 (メソッドマン) ---- 最後の End With が余分でした。 修正しました (seiya) ---- seiya様すいません。 今度はA4からA12にコードが転送されなくなりました。 (メソッドマン) ---- どのような結果になったのでしょう? MsgBoxは? (seiya) ---- Private Sub CommandButton1_Click() Dim r As Range, myList, i As Long, n As Long Dim msg As String, myLimit As Long With Worksheets("数量表").Range("a4:a12") Set r = .Find("", .Cells(.Cells.Count), , , , xlNext) If r Is Nothing Then MsgBox "No room to dump the data" Exit Sub End If n = r.Row: myLimt = .Cells(.Cells.Count).Row End With myList = [{2,7,9,5,11,13,15,17,19}] For i = 1 To UBound(myList) If Me.Controls("TextBox" & myList(i)).Value = "" Then '<- 修正 11:16 If n > myLimit Then msg = msg & vbLf & "TextBox" & myList(i) Else Worksheets("数量表").Cells(n, "a").Value = _ Me.Controls("TextBox" & myList(i)).Value n = n + 1 End If End If Next If Len(msg) Then MsgBox "以下の" & UBound(Split(msg, vbLf)) & _ "件は 転記漏れです。" & msg End If End Sub TextBox2にだけ入力してボタン押すと、"以下の8件は転記漏れです。"とTextBox2以外のTextBox番号が表示されました。 でも数量表にはtextBox2の値も転記されませんでした。 (メッソドマン) ---- ですよね... If Me.Controls("TextBox" & myList(i)).Value = "" Then は If Me.Controls("TextBox" & myList(i)).Value <> "" Then ^^^^ ですね (seiya) ---- Private Sub CommandButton1_Click() Dim r As Range, myList, i As Long, n As Long Dim msg As String, myLimit As Long With Worksheets("数量表").Range("a4:a12") Set r = .Find("", .Cells(.Cells.Count), , , , xlNext) If r Is Nothing Then MsgBox "No room to dump the data" Exit Sub End If n = r.Row: myLimt = .Cells(.Cells.Count).Row End With myList = [{2,7,9,5,11,13,15,17,19}] For i = 1 To UBound(myList) If Me.Controls("TextBox" & myList(i)).Value <> = "" Then 'こちらですか? If n > myLimit Then msg = msg & vbLf & "TextBox" & myList(i) Else Worksheets("数量表").Cells(n, "a").Value = _ Me.Controls("TextBox" & myList(i)).Value n = n + 1 End If End If Next If Len(msg) Then MsgBox "以下の" & UBound(Split(msg, vbLf)) & _ "件は 転記漏れです。" & msg End If End Sub 構文エラーですとでちゃいました。 (メッソドマン) ---- <> = じゃなくて <> だけです。 コードは修正済み (seiya) ---- すいません読み違えてました。 訂正して再度実行しました。 次は "以下の1件は転記漏れです。 TextBox2" とでました。 sheets"数量表"には転記されません。 何度もすいません。 (メッソッドマン) ---- myLimitの取得がおかしいのかな? n = r.Row : myLimt = .Cells(.Cells.Count).Row ^^^ を n = r.Row : myLimt = Cells(.Cells.Count).Row に変更してみてください (seiya) ---- 変更しました。 またも上記と同様の"以下の1件は転記漏れです。 TextBox2" とでました。 (メッソッドマン) ---- これを実行してメッセージを読んでください。 Private Sub CommandButton1_Click() Dim r As Range, myList, i As Long, n As Long Dim msg As String, myLimit As Long With Worksheets("数量表").Range("a4:a12") Set r = .Find("",.Cells(.Cells.Count) , , , , xlNext) If r Is Nothing Then MsgBox "No room to dump the data" Exit Sub End If n = r.Row : myLimt = .Cells(.Cells.Count).Row End With MsgBox "n = " & n & vbLf & "myLimit = " & myLimit End Sub (seiya) ---- メッセージがでました。 n = 4 myLimit = 0 です。 (メッソッドマン) ---- なぜそうなるのかわかりませんが... n = r.Row : myLimt = .Cells(.Cells.Count).Row を n = r.Row : myLimt = .Rows.Count + .Row - 1 に変更してください。 (seiya) ---- 先ほどと同様のメッセージになりました。 なぜなのでしょうか。 教えていただくままにしていながら内容が理解できずに、本当に申し訳ありません。 (メッソッドマン) ---- 大変なポカをやっていました... スペルミスです。 0 になるわけです... myLimt = .Rows.Count + .Row - 1 ^^^^^^ は myLimit = .Rows.Count + .Row - 1 ^^^^^^^ (seiya) ---- すいません遅くなりました。 変更して実行しましたメッセージがでました。 n = 4 myLimit = 12 です。 (メッソッドマン) ---- これでよいと思いますが? Private Sub CommandButton1_Click() Dim r As Range, myList, i As Long, n As Long Dim msg As String, myLimit As Long With Worksheets("数量表").Range("a4:a12") Set r = .Find("",.Cells(.Cells.Count) , , , , xlNext) If r Is Nothing Then MsgBox "No room to dump the data" Exit Sub End If n = r.Row : myLimit = .Rows.Count + .Row - 1 End With myList = [{2,7,9,5,11,13,15,17,19}] For i = 1 To UBound(myList) If Me.Controls("TextBox" & myList(i)).Value <> "" Then If n > myLimit Then msg = msg & vbLf & "TextBox" & myList(i) Else Worksheets("数量表").Cells(n, "a").Value = _ Me.Controls("TextBox" & myList(i)).Value n = n + 1 End If End If Next If Len(msg) Then MsgBox "以下の" & UBound(Split(msg, vbLf)) & _ "件は 転記漏れです。" & msg End If End Sub (seiya) ---- できました!! seiya様お手を煩わせて申し訳ありませんでした。 ありがとうございました。 無理を承知でお願いしたい事がひとつあります。 頂いたコードがどう動いてどうなるのかというのをコードに沿って教えて頂きたいのですが、 もしお時間がありましたら、どうかよろしくお願い致します。 (メソッドマン) ---- メソッドマンさん、 Helpを見るなりして解読し、それでもわからないところだけ指摘してください。 (seiya) ---- はい!! 頑張って解読していきたいと思います!! 行き詰まった時にはどうか宜しくお願い致します! (メソッドマン) ...
https://www.excel.studio-kazu.jp/wiki/kazuwiki/200812/20081207220415.txt - [detail] - similar
PREV NEXT
Powered by Hyper Estraier 1.4.13, with 97044 documents and 608215 words.

訪問者:カウンタValid HTML 4.01 Transitional