Home |
Search |
Today's Posts |
#11
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Single-stepping (F8) thru your code immediately shows
Rows(iRow).Insert Selection.EntireRow.Insert is what is giving you two inserted rows. I'm learning a lot -- I've added comments to your code. Private Sub AddRow_Section1_Click() ' insert row before button Dim iRow&, MyRow&, MyRan$ iRow = Addrow_Section1.TopLeftCell.Row Cells(iRow, 1).Select Rows(iRow).Insert ' Selection.EntireRow.Insert ' delete this ' At this point you can (maybe) copy formats and formulae: Rows(iRow - 1).Copy Rows(iRow).PasteSpecial xlPasteFormats Rows(iRow).PasteSpecial xlPasteFormulas ' Unfortunately, this also pastes values (XL97), ' so you might as well Rows(iRow - 1).Copy Rows(iRow) ' instead of the above 3 lines. ' But you don't want old values: Cells(iRow, 3) = "" ' .Clear clears formats ' There are probably things to change: With Rows(iRow).Borders(xlInsideVertical) .LineStyle = xlContinuous .Weight = xlThick .ColorIndex = xlAutomatic End With 'So I think this does it ' ' select the range for borders ' MyRow = ActiveCell.Row ' MyRan = "A" & MyRow & ":" & "P" & MyRow ' Range(MyRan).Select ' ' Now do borders ' 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 ' MyRan = "A" & MyRow ' Range(MyRan).Select ' I would think better is Rows(iRow).Select ' or Cells(iRow, 1).Select End Sub "Stacie wrote: Works like a charm... BUT.. now how do I get it to keep the borders just like the line above it? I used the code to insert a row above the button... It currently keeps the same row shading (yellow), but I need it to keep the same border (which is just the plain black border around each cell). I tried the code below, however, it kinda goofs up and gives me 2 rows, and the top row keeps the borders, and the second row is just yellow?!?!?! What am I missing here? [code is above] |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Calculating When Somebody Reaches a Certain Age | Excel Discussion (Misc queries) | |||
formula for if a cell reaches a certain value | Excel Discussion (Misc queries) | |||
adding rows, pasting values then empty sheet | Excel Worksheet Functions | |||
Automaticall e-mail me when cell value reaches a value | Excel Worksheet Functions | |||
HELP ME !! PLEASE!! How do I highlight a cell when it reaches a va | Excel Worksheet Functions |