LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #11   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 176
Default adding row when user reaches the last available empty row

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Calculating When Somebody Reaches a Certain Age Popey Excel Discussion (Misc queries) 4 May 4th 09 12:22 PM
formula for if a cell reaches a certain value Lise Excel Discussion (Misc queries) 5 January 20th 09 05:21 AM
adding rows, pasting values then empty sheet misscharliebrown Excel Worksheet Functions 2 October 30th 08 03:07 AM
Automaticall e-mail me when cell value reaches a value [email protected] Excel Worksheet Functions 2 December 13th 07 07:10 PM
HELP ME !! PLEASE!! How do I highlight a cell when it reaches a va ANDREW_B Excel Worksheet Functions 1 December 2nd 04 11:14 AM


All times are GMT +1. The time now is 11:03 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"