トップページ > プログラム > 2014年06月27日 > fv43ADTP

書き込み順位&時間帯一覧

5 位/217 ID中時間01234567891011121314151617181920212223Total
書き込み数2400100000000000000000007



使用した名前一覧書き込んだスレッド一覧
デフォルトの名無しさん
Excel VBA 質問スレ Part33

書き込みレス一覧

Excel VBA 質問スレ Part33
942 :デフォルトの名無しさん[sage]:2014/06/27(金) 00:18:06.71 ID:fv43ADTP
>>936

Dim startcell As Range, endcell As Range
Dim lineshape As Shape

Set startcell = Sheet1.Range("B2")
Set endcell = Sheet1.Range("D3")

Set lineshape = Sheet1.Shapes.AddLine( _
startcell.Left + startcell.Width / 2, _
startcell.Top + startcell.Height / 2, _
endcell.Left + endcell.Width / 2, _
endcell.Top + endcell.Height / 2)

lineshape.line.ForeColor.RGB = vbBlack

もう来るなよ
Excel VBA 質問スレ Part33
947 :デフォルトの名無しさん[sage]:2014/06/27(金) 00:53:49.28 ID:fv43ADTP
>>946
素直にコード書いてくださいって言えよ
Excel VBA 質問スレ Part33
955 :デフォルトの名無しさん[sage]:2014/06/27(金) 01:45:43.30 ID:fv43ADTP
>>954
たぶんベタにやるしかない。速度差なんて大差無いと思うが
ベタにやってみた
Excel VBA 質問スレ Part33
956 :デフォルトの名無しさん[sage]:2014/06/27(金) 01:47:19.39 ID:fv43ADTP
改行多すぎるらしい
前半

Function DataArea(checkarea As Range) As Range

Dim retarea As Range
Dim row1 As Long, col1 As Long, row2 As Long, col2 As Long
Dim r As Range, i As Long

'上
For Each r In checkarea.Rows
Debug.Print "r1 count=" & WorksheetFunction.CountA(r)
If WorksheetFunction.CountA(r) > 0 Then
row1 = r.Row
Exit For
End If
Next

'左
For Each r In checkarea.Columns
If WorksheetFunction.CountA(r) > 0 Then
col1 = r.Column
Exit For
End If
Next

If row1 = 0 Or col1 = 0 Then
MsgBox "範囲内にデータなし"
Exit Function
End If
Excel VBA 質問スレ Part33
957 :デフォルトの名無しさん[sage]:2014/06/27(金) 01:47:49.81 ID:fv43ADTP
後半

'下
For i = checkarea.Rows.Count To 1 Step -1
If WorksheetFunction.CountA(checkarea.Rows(i)) > 0 Then
row2 = checkarea.Rows(i).Row
Exit For
End If
Next

'右
For i = checkarea.Columns.Count To 1 Step -1
If WorksheetFunction.CountA(checkarea.Columns(i)) > 0 Then
col2 = checkarea.Columns(i).Column
Exit For
End If
Next

With checkarea.Worksheet
Set retarea = .Range(.Cells(row1, col1), .Cells(row2, col2))
End With

Set DataArea = retarea

End Function
Excel VBA 質問スレ Part33
958 :デフォルトの名無しさん[sage]:2014/06/27(金) 01:51:47.61 ID:fv43ADTP
これでたとえばセル範囲選択して
MsgBox DataArea(Selection).Address
とかで行けるんじゃね
問題になるほど遅いとは思わんが
Excel VBA 質問スレ Part33
977 :デフォルトの名無しさん[sage]:2014/06/27(金) 04:36:07.16 ID:fv43ADTP
>>968
シート全選択で、実際にデータ入ってる範囲はどのくらいなんだ?

つか今気づいたんだが、(一旦保存して開き直して)UsedRange見れば良いんじゃないか


※このページは、『2ちゃんねる』の書き込みを基に自動生成したものです。オリジナルはリンク先の2ちゃんねるの書き込みです。
※このサイトでオリジナルの書き込みについては対応できません。
※何か問題のある場合はメールをしてください。対応します。