Using VBA to select the last row of a dynamic table

floragray

New Member
Joined
Jul 22, 2013
Messages
19
Hi All,

I have a table(not pivot table but a regular table) in Excel 2010 that is connected to a database and is constantly refreshing data.
I need to apply a filter that somehow gives me the last row of data, whichever that is.
I'm not soo good at VBA - could someone please help me out?

Thanks a ton:)
 
You are welcome.

Michael, no excel... the horror :). No email :pray:.
















Alright,, next challenge,, would be really grateful if you could helpp!

So i have a table resembling this(its gets updated with new rows when data is refreshed):


Serial NumberC1C2C3
150455
255505
365587
470700
5504010
660555
756506
867607
945540

<tbody>
</tbody>


I need to create a Button of sorts, that when clicked throws an Input Box asking used to "Enter specific serial number"
and then when the user enters for example "7",,,the table filter out the record for Serial number 7 and all the other records are hidden.






Sub ShowSpecific()




Dim myRange As Range




Set myRange = Sheets("XYZ Report").ListObjects("Table_Default__STG2_REP_XYZ_SOURCE").InputBox(Prompt:="Please select a Serial Number", Type:=8)


End Sub




Thanksss:)
 
Upvote 0

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
Upvote 0
I can't do any testing (excel 2003 at home) but try: (source Working with Lists and Tables in Excel 2007: VBA Samples (Part 2 of 2) (May 2009))


Rich (BB code):
FilterCriteria = InputBox("What Serial Number do you want to filter on?", _
"Type in the filter item.") 
Sheets("XYZ Report").ListObject("Table_Default__STG2_REP_XYZ_SOURCE").Range.AutoFilter _
Field:=1, Criteria1:="=" & FilterCriteria






Hi Teeroy,

Thanks a ton for the help.

But i keep getting ''Run time error 438 - Object doesnt support this property or method''

ive tried a few permutations and combinations,, but it doesnt work:(
 
Upvote 0
My Fault :oops:. When I spliced this together with your object names I overwrote the "s" in ListObjects.

So change
ListObject to ListObjects and it should work.
 
Upvote 0
My Fault :oops:. When I spliced this together with your object names I overwrote the "s" in ListObjects.

So change
ListObject to ListObjects and it should work.







You're saving the day today!
It workedd....thanksss a tonn
:D:D:D:D
 
Upvote 0
You're welcome. And your questions have given me an idea to modify a project at work so it's win-win.
 
Upvote 0
You're welcome. And your questions have given me an idea to modify a project at work so it's win-win.







Oh Super! Stuck at another point,,,,(HELP!!)
For this same table:



Serial NumberC1C2C3
1504010
239930
329524
432230
521120
6321220
747740

<tbody>
</tbody>
Sheets("Report ABC").ListObjects("Table_Default__STG2_REP_ABC")



I need to create a Button of sorts, that when clicked throws an Input Box asking used to "Enter a range of serial numbers"
and then when the user to be able to enter individual and well as a range of serial number. For Example (1,2,4-7) or (1-3,7-9,11).
And as a result the table filter these in.

Is it possible?


Thanksss a tonn!
 
Upvote 0

Forum statistics

Threads
1,216,101
Messages
6,128,837
Members
449,471
Latest member
lachbee

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top