プロが教える店舗&オフィスのセキュリティ対策術

困っています。どなたか教えてください。
下記のように作成しましたが、
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
まだまだ続きますが・・・・。

よろしくお願いいたします。

A 回答 (2件)

>まだまだ続きますが・・・・。



どこが不明なのでしょう?

いずれにしても
>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

補足日時:2005/06/26 12:16
    • good
    • 0

最初に、


c = ActiveCell.Row

を入れれば、特に、書かれている限りは、問題はないと思いますが、プロシージャと書きながら、途中を抜き出したものですし、説明もほとんどないので、正確な解答はできないと思います。

例えば、
bolFlg = True
なぜ、フラグを取っているのか、理由が見えてきません。
    • good
    • 0

お探しのQ&Aが見つからない時は、教えて!gooで質問しましょう!