Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 24th, 2012, 05:52 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 836
Thanks: 0
Thanked 0 Times in 0 Posts
Default Determine range of values?

Hi all,

Sorry for the n00b post. I have searched around for the answer to this and couldn't find what I was looking for.

In Excel 2007 & 2010, you can click the "Format as Table" button on the Home ribbon and Excel automagically figures out the range of cells that contain the table data you want to format.

How can I do this in VB? I've seen some really hokey solutions using loops, but that seems like a terrible way to go... in pseudocode, these solutions look like:

Start at A1 and check each value column-by-column until you find a NULL. Then go back one column and that's your column range boundary.

Start at A1 and check each value row-by-row until you find a NULL. Then go up one row and that's your row range boundary.

Your table range is A1 : LastCol, LastRow


I can't believe that this is the best way to solve this...
__________________
Take care,

Nik
 
Old May 26th, 2012, 09:23 AM
Friend of Wrox
 
Join Date: Sep 2005
Posts: 812
Thanks: 1
Thanked 53 Times in 49 Posts
Default

Hi Nik

Have you tried UsedRange. It should work for you

Regards
Shasur
__________________
C# Code Snippets (http://www.dotnetdud.blogspot.com)

VBA Tips & Tricks (http://www.vbadud.blogspot.com)





Similar Threads
Thread Thread Starter Forum Replies Last Post
Distinct Values and variable dynamic range patrunjel BOOK: Excel VBA 24-Hour Trainer 0 April 6th, 2012 11:00 AM
Value matching with Range values manojkumarsoni Excel VBA 2 April 6th, 2010 08:53 AM
Out of range values stored in tinyint column BorisG SQL Server 2005 7 July 14th, 2007 12:34 PM
Filter grid view results by range of values srinredd59 ASP.NET 2.0 Professional 0 December 27th, 2006 03:55 PM
including unique values from a range into a combo Kaustav Excel VBA 0 November 6th, 2006 09:17 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.