0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

選択範囲の小数点を切り上げるマクロ

Last updated at Posted at 2022-02-18

1500行くらい修正しなきゃいけなかったため急いで書いたメモ。
自己責任でお願いします。

Sub RangeCelection()
Dim i As Range

'選択行をまわす
For Each i In Selection
    '切り上げ&チェック関数呼び出し
    Call RoundUp(i)
Next
End Sub
Sub RoundUp(ByVal c As Range)
Dim target As Double
Dim target2 As Long

target = c.Value

'数値以外除外
If IsNumeric(target) Then
    Exit Sub
End If

'整数除外
If target = Int(target) Then
    Exit Sub
End If

'切り上げ
target2 = Application.WorksheetFunction.RoundUp(target, 0)

'イミディエイトに変更行と前の値を出しておいた
Debug.Print c.Row;
Debug.Print c.Value

c.Value = target2
End Sub
0
1
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
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?