Created
February 7, 2014 07:44
-
-
Save katorie/8858705 to your computer and use it in GitHub Desktop.
弥生販売から作成した見積控えデータを見やすいように整理する
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Option Explicit | |
'見積控えのデータを整理する | |
'---必要のない列を削除 | |
'---消費税の行を削除 | |
'---数量、単価、金額の欄が「0」だったら文字色を白にする | |
Sub 見積控え整理() | |
'---画面が動かないよう固定 | |
Application.ScreenUpdating = False | |
'---必要のない列を削除する--- | |
'---うしろの列から削除しないと、削除中にずれる--- | |
Range("AA1, Y1, W1, U1, T1, S1, Q1, P1, N1, M1, J1, H1, G1, F1, E1, D1").EntireColumn.Delete | |
'---数量、単価、金額の欄が「0」だったら文字色を白にする--- | |
With Columns("I:K").FormatConditions | |
.Add Type:=xlCellValue, Operator:=xlEqual, Formula1:="=0" | |
.Item(1).Font.ColorIndex = 2 | |
End With | |
'---6行目からデータの最終行までループする | |
Dim i As Long | |
For i = 6 To Range("C65536").End(xlUp).Row | |
'---消費税の行を削除 | |
If Cells(i, 8) = "《消費税》" Then | |
Rows(i).Delete | |
End If | |
'---見積日から担当者名までを選択 | |
With Range(Cells(i + 1, 2), Cells(i + 1, 7)) | |
'---見積番号が前の行と同一なら文字色を白に、異なるなら文字色を黒に変更 | |
If Cells(i, 3) = Cells(i + 1, 3) Then | |
.Font.ColorIndex = 2 | |
Else | |
.Font.ColorIndex = 1 | |
End If | |
End With | |
Next | |
'---画面固定を解除 | |
Application.ScreenUpdating = True | |
End Sub | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment