Logo 
Search:

MS Office Answers

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds
  Question Asked By: Bryant Smith   on Jan 30 In MS Office Category.

  
Question Answered By: Cedric Sanders   on Jan 30

The parentheses problem was my last
attempt to get away from an error message that said VBA was looking
for another ")", and I've since gone back to the way that you suggest.


Here's where I started:
I have a database that has 3 columns of dollars that I wish to
subtotal, and the following works fine.
Range("B2:T43").Select
Selection.Subtotal GroupBy:=5, Function:=xlSum,_
TotalList:=Array(9, 15, 18) _
, Replace:=True, PageBreaks:=False, SummaryBelowData:=True
Range("V4").Select

My problem is that T43 is the bottom row now...but it will change as
I add additional lines to the database. I want to select the cells
starting at B2 and going down to T43, or below as new lines are added.

To do this I looked for the correct bottom row with this:

lastrow = ActiveSheet.UsedRange.Rows.Count

This is correct. It returns row 43 today, and will total 44, 45, etc.
as new lines are added to the database.
Hi David,

As you can see, I stored the 43 to lastrow, and then dropped lastrow
into the following:

With Worksheets(1)
.Range (.Cells(2, 10), .Cells(20, lastrow)).Select
End With

which makes the range  line read:

.Range(.Cells(2, 10), .Cells(20, 43)).Select

...but that doesn't work  either, the error message says it is
expecting a "=".

Hope this helps to explain my predicament. I am very grateful that
you are willing to help me. I am really "stuck"!

Share: 

 

This Question has 6 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on highlight a range using a named range Or get search suggestion and latest updates.


Tagged: