
困っています。どなたか教えてください。
下記のように作成しましたが、
A列に文字が入っていたら、上下に線を引くというプロシージャにしたいと思っています。
If Cells(c, 4) = "" Then
Range(Cells(c, 1), Cells(c, 6)).Select
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlDot
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
bolFlg = True
Else
まだまだ続きますが・・・・。
よろしくお願いいたします。
No.1ベストアンサー
- 回答日時:
>まだまだ続きますが・・・・。
どこが不明なのでしょう?
いずれにしても
>If Cells(c, 4) = "" Then
では、Cells(c, 1)にしないとA列にはなりませんよね?
文字が入っていたらと言う条件なら、Cells(c, 1) <> "" とします。
この回答への補足
早速のご回答ありがとうございます。
空白でも、文字が入っていても線を引けてしまいます。A列に文字が入ったら線を引くにしたいのです。
全文表示します。
Dim bolFlg As Boolean
Dim intCount As Integer
Range("a1").Select
ActiveCell.CurrentRegion.BorderAround xlContinuous, xlThin
最下行 = Range("a1").CurrentRegion.Rows.Count
'最下列 = Range("a1").CurrentRegion.Column.Count
bolFlg = True: intCount = 0
For c = 1 To 最下行 - 1
intCount = intCount + 1
If Cells(c, 4) = "" Then
Range(Cells(c, 1), Cells(c, 6)).Select
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlDot
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
bolFlg = True
Else
If bolFlg = True Then
Range(Cells(c, 1), Cells(c, 6)).Select
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlDot
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
Else
Range(Cells(c, 1), Cells(c, 6)).Select
With Selection.Borders(xlEdgeTop)
.LineStyle = xlDot
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
End If
bolFlg = False
If Cells(c, 4) = "数量" Then
bolFlg = True
End If
If c <= 56 Then
If intCount = 55 Then
Range(Cells(c + 1, 1), Cells(c + 1, 6)).Select
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlDot
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
intCount = 0
End If
Else
If intCount = 56 Then
Range(Cells(c + 1, 1), Cells(c + 1, 6)).Select
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlDot
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
intCount = 0
End If
End If
End If
ActiveCell.Offset(1, 0).Select
Next c
Range(Cells(56, 1), Cells(56, 6)).Select
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
End Sub
No.2
- 回答日時:
最初に、
c = ActiveCell.Row
を入れれば、特に、書かれている限りは、問題はないと思いますが、プロシージャと書きながら、途中を抜き出したものですし、説明もほとんどないので、正確な解答はできないと思います。
例えば、
bolFlg = True
なぜ、フラグを取っているのか、理由が見えてきません。
お探しのQ&Aが見つからない時は、教えて!gooで質問しましょう!
このQ&Aを見た人はこんなQ&Aも見ています
関連するカテゴリからQ&Aを探す
このQ&Aを見た人がよく見るQ&A
人気Q&Aランキング
-
4
callで順に実行されるプロシー...
-
5
VBA プロシージャの名前の取得
-
6
Excel VBAで「プログラム実行」...
-
7
excel/vba/public変数
-
8
或るプロシージャの呼び出し元判定
-
9
Accessでグローバル変数を宣言...
-
10
ACCESS マクロをモジュールに変...
-
11
DB2でのストアドプロシージャの...
-
12
VBA 「文字が入っていたら、...
-
13
【Excel VBA】 WorksheetやRa...
-
14
PL/SQLのエラーについて
-
15
見たことのない形式で日付が表...
-
16
キャッシュを使わずにSELECTを...
-
17
テーブルの主キーをdate型...
-
18
Statement ignored というエラー
-
19
WHERE句はJOIN結合前結合後どち...
-
20
全角空白のTRIMができない...
おすすめ情報
公式facebook
公式twitter