View Single Post
  #17   Report Post  
Posted to microsoft.public.excel.programming
Stopher Stopher is offline
external usenet poster
 
Posts: 67
Default Finding last cell and insert line


Stopher wrote:

Stopher wrote:
Matt wrote:
One other question -

Say I want to hide rows after I've done all of the things we have gotten so
far with the code...and I want it to start after the sums and everything
(very next row) and go to a specific row....I h ave this so far, but am not
sure about the syntax cause it isn't working....thanks:


Selection.EntireRow.Select
Rows(Selection, 1001).Select
Selection.EntireRow.Hidden = True

So I want it to go down to row 1001 - do I just add 1000 to selection? i.e.
Rows(Selection, Selection + 1000)?

"Matt" wrote:

Thank you very much for your help on this Stopher!

"Stopher" wrote:

On the 400 error, all I can find is that if you have pasted the code
into a sheets secific area, you should paste it in a module.

So either on the VBA page insertmodule and paste in there, or on the
sheet make it into a windowed view and right click on the title bar and
select view code and paste there.

Hope this solves the problem.

Stopher



So you want to do the formual add on the top block of contiguous data,
and then hide everything else underneath??


Don't know which code your applying it to but...

Sub AddFormulas2()

Dim RowCount As Integer

Range("A1").Select


Range(Selection, Selection.End(xlDown)).Select
RowCount = Selection.Count + 2
Cells((Selection.Count + 1), 1).Select


Selection.EntireRow.Insert
ActiveCell.Range( _
"C1,F1:J1").FormulaR1C1 = "=Sum(R2C:R[-1]C)"
ActiveCell.Offset(2, 0).Select

Range("A" & RowCount, "G" & RowCount + 1002).Select
Selection.EntireRow.Hidden = True


End Sub

Just added a variable to hold the row number and the hid A - G if this
isn't enough then just change the G, not exactly flexible coding but it
will do.

Stopher


Well there you go just change the "G" to an "A" anyways because it
doesn't only hide the selection but the entire row of every row
selected.

Stopher