473,396 Members | 1,786 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Trying to create a range dynamically

hello,

This is a basic questions... i have just started using vb....

I want to figure out how to create a range dynamically.

Say I have some data in a variable number of columns, in this example
3 - A, B, & C

Eg.

A B C
1
2
3 2 2 2
4 3 3 3
5 4 4 4

I want to write a sub/function that returns a range that contains all
the non-empty values in those columns.
I will know where the non-empty values begin, so all I need to find
out is the last non-empty cell, and create
a range out of this.

The range I want in this instance is: A3:D5

Can anyone help with this?

T

Feb 28 '07 #1
1 1225
On Feb 28, 10:55 am, "Tom O'Brien" <tomobrien2...@gmail.comwrote:
hello,

This is a basic questions... i have just started using vb....

I want to figure out how to create a range dynamically.

Say I have some data in a variable number of columns, in this example
3 - A, B, & C

Eg.

A B C
1
2
3 2 2 2
4 3 3 3
5 4 4 4

I want to write a sub/function that returns a range that contains all
the non-empty values in those columns.
I will know where the non-empty values begin, so all I need to find
out is the last non-empty cell, and create
a range out of this.

The range I want in this instance is: A3:D5

Can anyone help with this?

T
Is the data in an array? My first guess would be a nested loop: the
inner one to go across the columns and the outer one to go down the
rows...
For i = 0 To noOfRows
For j = 0 To noOfColumns
'check for empty string to start and to start (presumably with a
boolean)
'keeping track of where you started and where you stopped; then
return that
Next
Next

Depending on what you need you could just return the formatted string
"A3:D5" (or would it be C5 in the example?), though I'd prefer passing
back an object with start and end properties: objGrid.Start.Column =
0, objGrid.Start.Row = 2, objGrid.End.Column = 2, etc. (if zero-based,
otherwise, 1 and 3; 3 and 5)

Feb 28 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Bil Muh | last post by:
Esteemede Developers, I would like to Thank All of You in advance for your sincere guidances. I am developing a software using Visual C++ .NET Standard Edition with Windows Form (.NET)...
3
by: Kiyomi | last post by:
Hello, I create a Table1 dynamically at run time, and at the same time, I would like to create LinkButton controls, also dynamically, and insert them into each line in my Table1. I would...
2
by: xxbmichae1 | last post by:
I am writing a function that will create different type of input ranges, example one function that will create date range inputs with drop down calendars, another will be for currency ranges,...
3
by: James Wong | last post by:
Dear all, I have an old VB6 application which can create and access Excel object. The basic definition statements are as follows: Dim appExcel As Object Dim wkb1 As Excel.Workbook Dim wks1...
7
by: pmclinn | last post by:
I was wondering if it is possible to dynamically create a structure. Something like this: public sub main sql = "Select Col1, Col2 from Table a" dim al as new arraylist al =...
1
by: unsichtbar | last post by:
Sorry, but I'm pretty new to .NET/XML etc... I have the current code which I'm trying to output dynamically so it can be read into a flash file. The only issue is, it doesn't seem to actually do...
1
by: giloosh | last post by:
i would like to dynamically output such a selectbox below using php and mysql: <select> <option< 100 </option> <option100 to 150 </option> <option150 to 200 </option> <option200 to 250...
0
by: Hatem Nassrat | last post by:
on Wed Jun 13 10:17:24 CEST 2007, Diez B. Roggisch deets at nospam.web.de wrote: Well I have looked into this and it seems that using the list comprehension is faster, which is...
1
by: Kalkin | last post by:
Hi I am having trouble with creating a gridview dynamically. Any help would be much appreciated. The Problem: I have a range of dates that changes, i want those dates to be the column...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.