Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 58
Default finding UsedRange with sparse data

I am creating an addin that works with user created 'databases'.

Assume there is a 'database' that looks something like:

Name | Phone | Address | City | State
Dave | | | |
Thom | | | |
Mary | | | |
Joe | | | |
Beth | | | |
Sue |12345 | Home |Town |NY

It can be anywhere on a given worksheet, the only requirement is that
is have no blanks in the first row.
The 'database' is user created so the code doesn't know how many
columns or rows, or where the upper left corner is.

When the user clicks on a cell within the bounds of the 'database' and
then clicks on a menu button provided by the addin, some action is
taken on the database.

When the database is not sparse using activecell.currentregion works
fine. When the 'database' is sparse activecell.currentregion doesn't
work. e.g. user clicked on Mary's Address above.

Any suggestions on how to define the database (CurrentRegion) with
sparse data?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 703
Default finding UsedRange with sparse data

On 8 Jan., 00:02, dbKemp wrote:
I am creating an addin that works with user created 'databases'.

Assume there is a 'database' *that looks something like:

* Name | Phone | Address | City | State
* Dave * | * * * * * | * * * * * * *| * * * *|
* Thom *| * * * * * | * * * * * * *| * * * *|
* Mary * | * * * * * | * * * * * * *| * * * *|
* Joe * * | * * * * * | * * * * * * *| * * * *|
* Beth * | * * * * * | * * * * * * *| * * * *|
* Sue * * |12345 | Home * * |Town |NY

It can be anywhere on a given worksheet, the only requirement is that
is have no blanks in the first row.
The 'database' is user created so the code doesn't know how many
columns or rows, or where the upper left corner is.

When the user clicks on a cell within the bounds of the 'database' and
then clicks on a menu button provided by the addin, some action is
taken on the database.

When the database is not sparse using activecell.currentregion works
fine. *When the 'database' is sparse activecell.currentregion doesn't
work. *e.g. user clicked on Mary's Address above.

Any suggestions on how to define the database (CurrentRegion) with
sparse data?


Try

Activecell.end(xltoLeft).currentRegion

//Per
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 58
Default finding UsedRange with sparse data

On Jan 7, 6:29 pm, Per Jessen wrote:
On 8 Jan., 00:02, dbKemp wrote:



I am creating an addin that works with user created 'databases'.


Assume there is a 'database' that looks something like:


Name | Phone | Address | City | State
Dave | | | |
Thom | | | |
Mary | | | |
Joe | | | |
Beth | | | |
Sue |12345 | Home |Town |NY


It can be anywhere on a given worksheet, the only requirement is that
is have no blanks in the first row.
The 'database' is user created so the code doesn't know how many
columns or rows, or where the upper left corner is.


When the user clicks on a cell within the bounds of the 'database' and
then clicks on a menu button provided by the addin, some action is
taken on the database.


When the database is not sparse using activecell.currentregion works
fine. When the 'database' is sparse activecell.currentregion doesn't
work. e.g. user clicked on Mary's Address above.


Any suggestions on how to define the database (CurrentRegion) with
sparse data?


Try

Activecell.end(xltoLeft).currentRegion

//Per


Thanks. Good suggestion, poor example provided (on my part). There
could be a row with no name, but have a value in the state column.
Using a Activecell.end() function could end up 'finding' a 'island'
cell that has a value, but no other cells around with a value so the
CurrentRegion still wouldn't work.
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default finding UsedRange with sparse data


Have the user select the database and then feed the selection
address back to the user in a MsgBox for confirmation.
Then you verify it by checking that the top left and top right cells
contain "Name" and State" and that there at least two(?) rows in it.
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins / Excel Programming)



"dbKemp"

wrote in message
I am creating an addin that works with user created 'databases'.
Assume there is a 'database' that looks something like:

Name | Phone | Address | City | State
Dave | | | |
Thom | | | |
Mary | | | |
Joe | | | |
Beth | | | |
Sue |12345 | Home |Town |NY

It can be anywhere on a given worksheet, the only requirement is that
is have no blanks in the first row.
The 'database' is user created so the code doesn't know how many
columns or rows, or where the upper left corner is.
When the user clicks on a cell within the bounds of the 'database' and
then clicks on a menu button provided by the addin, some action is
taken on the database.
When the database is not sparse using activecell.currentregion works
fine. When the 'database' is sparse activecell.currentregion doesn't
work. e.g. user clicked on Mary's Address above.
Any suggestions on how to define the database (CurrentRegion) with
sparse data?
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 58
Default finding UsedRange with sparse data

On Jan 7, 6:38 pm, "Jim Cone" wrote:
Have the user select the database and then feed the selection
address back to the user in a MsgBox for confirmation.
Then you verify it by checking that the top left and top right cells
contain "Name" and State" and that there at least two(?) rows in it.
--
Jim Cone
San Francisco, USAhttp://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins / Excel Programming)

"dbKemp"

wrote in message
I am creating an addin that works with user created 'databases'.
Assume there is a 'database' that looks something like:

Name | Phone | Address | City | State
Dave | | | |
Thom | | | |
Mary | | | |
Joe | | | |
Beth | | | |
Sue |12345 | Home |Town |NY

It can be anywhere on a given worksheet, the only requirement is that
is have no blanks in the first row.
The 'database' is user created so the code doesn't know how many
columns or rows, or where the upper left corner is.
When the user clicks on a cell within the bounds of the 'database' and
then clicks on a menu button provided by the addin, some action is
taken on the database.
When the database is not sparse using activecell.currentregion works
fine. When the 'database' is sparse activecell.currentregion doesn't
work. e.g. user clicked on Mary's Address above.
Any suggestions on how to define the database (CurrentRegion) with
sparse data?


Thanks Jim. I currently check to see that the top row has no blanks
and that there are at least two rows once I define a CurrentRegion fro
the database. The headers are created by the user, so the code
doesn't know what headers to check for. I am reluctant, due to the
nature of the app to have the user verify every time they want the
addin operation to happen, therefore I would prefer not to have the
user verify the correct selection of the database. Because some of
the databases can be quite large I would prefer not to require the
user to select the entire database. I think some of my users might
even be upset if they had to select one of the header cells.


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default finding UsedRange with sparse data

I would think that there would be a rule that the first column couldn't be empty
either.

If that's true:

Dim LastRow as long
dim LastCol as long
dim myDBRng as Range

with worksheets("somesheetnamehere")
lastrow = .cells(.rows.count,"A").end(xlup).row
lastcol = .cells(1, .columns.count).end(xltoleft).column
set myDBRng = .range("A1",.cells(lastrow,lastcol))
end with

'do something with the myDBRng

dbKemp wrote:

I am creating an addin that works with user created 'databases'.

Assume there is a 'database' that looks something like:

Name | Phone | Address | City | State
Dave | | | |
Thom | | | |
Mary | | | |
Joe | | | |
Beth | | | |
Sue |12345 | Home |Town |NY

It can be anywhere on a given worksheet, the only requirement is that
is have no blanks in the first row.
The 'database' is user created so the code doesn't know how many
columns or rows, or where the upper left corner is.

When the user clicks on a cell within the bounds of the 'database' and
then clicks on a menu button provided by the addin, some action is
taken on the database.

When the database is not sparse using activecell.currentregion works
fine. When the 'database' is sparse activecell.currentregion doesn't
work. e.g. user clicked on Mary's Address above.

Any suggestions on how to define the database (CurrentRegion) with
sparse data?


--

Dave Peterson
Reply
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
Using LINEST with a sparse data row? Jo[_2_] Excel Programming 0 August 14th 07 07:06 PM
How do I graph a pivot table of sparse values? JDToellner Charts and Charting in Excel 0 December 17th 05 06:07 PM
Can you Sparse a field in Excel??? and Database Query?? TotallyConfused Excel Discussion (Misc queries) 3 December 6th 05 11:24 PM
Efficent way of setting sparse array of formulas? Josh Sale Excel Programming 5 August 16th 05 03:02 PM
finding last row number of UsedRange Jamie Martin[_2_] Excel Programming 4 September 26th 03 06:13 PM


All times are GMT +1. The time now is 10:19 AM.

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

About Us

"It's about Microsoft Excel"