0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

定型文

Posted at

Application.ScreenUpdating = False '画面更新非表示
Application.Calculation = xlCalculationManual '数式計算停止
Application.Calculation = xlCalculationAutomatic '数式計算再開
Application.EnableEvents = False '自動実行マクロ停止
Application.EnableEvents = True '自動実行マクロ再開

Dummy = ActiveSheet.UsedRange.Row '終端セル誤認バグ修正
Dummy = ActiveSheet.UsedRange.Column '終端セル誤認バグ修正
r = Range("A1").SpecialCells(xlLastCell).Row '一番下の行
c = Range("A1").SpecialCells(xlLastCell).Column '一番右の列

Cells(1, 1).Interior.Color = RGB(255, 255, 0) 'セル背景色
Cells(1, 1).Interior.Color = xlNone '塗りつぶしなし
Cells(1, 1).Font.Color = RGB(255, 0, 0) '文字色塗り

Columns(1).AutoFit '1列目列幅自動調整
Range(Cells(14, 2), Cells(14, 5)).Columns.AutoFit 'セル列幅調整
Columns("A:E").AutoFit 'セル列幅自動調整
Cells.EntireColumn.AutoFit 'シート全体の列幅自動調整
Cells.EntireRow.AutoFit 'シート全体の行の高さを自動調整

Range("C3:E5").Borders.LineStyle = xlContinuous 'セル罫線
Rows(3).Borders(xlEdgeTop).LineStyle = xlContinuous 'セル罫線上のみ
Range("C3:E5").Borders.LineStyle = xlLineStyleNone '上下左右の罫線を消す
Cells.Borders.LineStyle = xlLineStyleNone ' シート全体の罫線を消す

Cells(1, 1).AutoFilter 'フィルター
Cells(1, 1).AutoFilter 2, "あ" ' 2列目を"あ"でフィルター
Activesheet.ShowAllData '絞り込みクリア
Cells(1, 1).Sort key1:=Cells(1, 3), order1:=xlAscending, Header:=xlYes '昇順
Cells(1, 1).Sort key1:=Cells(1, 3), order1:=xlDescending, Header:=xlYes '降順

Application.StatusBar = "進行状況:" & i & "/" & r
Application.StatusBar = False
画面が固まる場合は一定カウント事にDoEventsを入れる。
If i Mod 100 = 0 Then
DoEvents
End If

'フィルタ後の先頭セル
With ActiveSheet.AutoFilter.Range
With .Resize(.Rows.Count - 1).Offset(1)
MsgBox .Columns(1).SpecialCells(xlCellTypeVisible).Cells(1).Address
End With
End With

クリップボードの参照設定
C:\Windows\System32\FM20.DLL」または「C:\Windows\SysWOW64\FM20.DLL」を参照

ClipBoard = Application.ClipboardFormats
If ClipBoard(1) = -1 Then
MsgBox "クリップボードは空です。", vbExclamation
Exit Sub
End If

'クリップボードを取得
With New MSForms.DataObject
.GetFromClipboard '変数のデータをDataObjectに格納する
MsgBox .GetText
End With
Application.CutCopyMode = False

'配列
Dim a() As Long
ReDim a(0)
・・・
i=i+1
ReDim Preserve a(i)

'二次元配列(こっちは少し遅い)
Dim tmp()
ReDim tmp(1 To r, 1 To c)

For i = 1 To r
For j = 1 To c
tmp(i, j) = Cells(i, j)
Next
Next

Range(Cells(1, 1), Cells(r, c)) = tmp

'二次元配列セルへのアクセス1回(cells(1,1)から限定)
Dim arr As Variant
arr = Range(Cells(1, 1), Cells(r, c))

For i = 1 To r
For j = 1 To c
Debug.Print tmp(i, j)
Next
Next

Erase arrData '配列初期化

Dim book1 As Workbook
Set book1 = Application.ActiveWorkbook '本エクセルをセット
Workbooks.Add '新規ブックを作成
Dim book2 As Workbook
Set book2 = Application.ActiveWorkbook '新規ブックをセット
book1.Worksheets(1).Cells(2, 6)

Worksheets.Add after:=Worksheets(Worksheets.Count)
Application.DisplayAlerts = False ' メッセージを非表示
Sheets(1).Delete
Application.DisplayAlerts = True ' メッセージを表示

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?