Hi All,
This is my very first VBA project, and I'm a bit lost. I've got this run-time error:
1004 - Application-defined or object-defined error.
Could you please take a look into the program and suggest me where could the problem be?
Sub FormatTable()
Dim i As Long
Dim rng As Range
Dim celle As Range
Set rng = Range(Sheets("Sheet1").[A1], Sheets("Sheet1").[A65536].End(xlUp))
For Each celle In rng
If IsEmpty(celle.value) and IsEmpty(celle.Offset(1, 0)) and IsEmpty(celle.Offset(2, 0)) and IsEmpty(celle.Offset(3, 0)) Then
celle.select
Range("A1:H2").Select
Selection.Copy
Range("celle.offset(1,0)").Select
ActiveSheet.Paste
Range("celle.offset(-1,0)").Select
Selection.Font.bold = True
Range("celle.offset(5,0)").Select
Selection.CurrentRegion.Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlInsideVertical)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlInsideHorizontal)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
end if
next celle
end sub
Thank you so much:-)
beacska
Bookmarks