ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   problem with code (https://www.excelbanter.com/excel-programming/387894-problem-code.html)

MicrosoftNews

problem with code
 


Hi all,

I've got a problem in the following code which should create line around
some cells.

There is another part of code which fills a summary under a data sheet.

##########
Sub Rahmen_ziehen()

Dim zeile As Long

zeile = Cells.Find("*", [A1], , , xlByRows, xlPrevious).Row

Range("U & zeile + 2:V & zeile + 6").Select
'---- here is the problem !!!!!!!!!!!!

Range("V" & zeile + 6).Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
Selection.Borders(xlInsideVertical).LineStyle = xlNone
With Selection.Borders(xlInsideHorizontal)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With

End Sub
#############################################

But I don't know what's wrong. Can anybody help ?

greetings achim



Vergel Adriano

problem with code
 
Hi,

Try it this way:


Range("U" & (zeile + 2) & ":V" & (zeile + 6)).Select


--
Hope that helps.

Vergel Adriano


"MicrosoftNews" wrote:



Hi all,

I've got a problem in the following code which should create line around
some cells.

There is another part of code which fills a summary under a data sheet.

##########
Sub Rahmen_ziehen()

Dim zeile As Long

zeile = Cells.Find("*", [A1], , , xlByRows, xlPrevious).Row

Range("U & zeile + 2:V & zeile + 6").Select
'---- here is the problem !!!!!!!!!!!!

Range("V" & zeile + 6).Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
Selection.Borders(xlInsideVertical).LineStyle = xlNone
With Selection.Borders(xlInsideHorizontal)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With

End Sub
#############################################

But I don't know what's wrong. Can anybody help ?

greetings achim




JE McGimpsey

problem with code
 
Try:

Range("U" & zeile + 2 & ":V" & zeile + 6).Select

In article ,
"MicrosoftNews" wrote:

Hi all,

I've got a problem in the following code which should create line around
some cells.

There is another part of code which fills a summary under a data sheet.

##########
Sub Rahmen_ziehen()

Dim zeile As Long

zeile = Cells.Find("*", [A1], , , xlByRows, xlPrevious).Row

Range("U & zeile + 2:V & zeile + 6").Select
'---- here is the problem !!!!!!!!!!!!

Range("V" & zeile + 6).Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
Selection.Borders(xlInsideVertical).LineStyle = xlNone
With Selection.Borders(xlInsideHorizontal)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With

End Sub
#############################################

But I don't know what's wrong. Can anybody help ?

greetings achim


MicrosoftNews

problem with code
 
Thanks very much :-) you're great


"MicrosoftNews" schrieb im Newsbeitrag
...


Hi all,

I've got a problem in the following code which should create line around
some cells.

There is another part of code which fills a summary under a data sheet.

##########
Sub Rahmen_ziehen()

Dim zeile As Long

zeile = Cells.Find("*", [A1], , , xlByRows, xlPrevious).Row

Range("U & zeile + 2:V & zeile + 6").Select '---- here is the problem
!!!!!!!!!!!!

Range("V" & zeile + 6).Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
Selection.Borders(xlInsideVertical).LineStyle = xlNone
With Selection.Borders(xlInsideHorizontal)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With

End Sub
#############################################

But I don't know what's wrong. Can anybody help ?

greetings achim





All times are GMT +1. The time now is 01:34 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com