Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
HBS HBS is offline
external usenet poster
 
Posts: 2
Default Selecting used part of a range

I am pretty new to VBA, so this may be obvious, but I can't figue it
out. Like they say, there are no stupid questions, only stupid people
that ask them.

Let me describe my sheet first.

I have a form for data input. There is a column header row in row 1
and a row number column in column A. The data starts in B1, five
columns and 30 rows. I have a named range(called "range")that
references B2:F31. There is no data to the right or below the table.
The data input may be less than 30 items, so all the rows may not be
full. I need to check to see if all the columns in the used rows have
data in them. I have tried several variations using
SpecialCells(xlCellTypeLastCell) to determine the used range to no
avail. For example,

range(range("b2"),range("range").SpecialCells(xlCe llTypeLastCell)).select

selects B2:H31. Why it goes out to column H I don't know. I set up a
new spreadsheet with a simplified version of my form and it did the
same thing, selecting 2 columns to the right of my last column. I am
not so much interested in why that happened as I am in just being able
to determine the used part of my range

In a nutshell:

I have a range B2:F31
A varying number of rows will have data, the remaining will be blank.
All the blank rows will be at the bottom, all filled rows at the top,
starting with cell b2.
I want to check the range B2:F?? to see if there are any blank cells
using COUNTBLANK or something simlilar. I just can't selct the correct
range.

Can anyone give me any insight? Thanks.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default Selecting used part of a range

Do I understand you correctly or am I one of the stupid people ?

blankcells=0
nonblankcells=0
myRange=Range("B2:F31")
For each c in myRange
if isblank(c.value) then blankcells = blankcells + 1 else nonblankcells
= nonblankcells + 1
Next

Chris

"HBS" wrote in message
om...
I am pretty new to VBA, so this may be obvious, but I can't figue it
out. Like they say, there are no stupid questions, only stupid people
that ask them.

Let me describe my sheet first.

I have a form for data input. There is a column header row in row 1
and a row number column in column A. The data starts in B1, five
columns and 30 rows. I have a named range(called "range")that
references B2:F31. There is no data to the right or below the table.
The data input may be less than 30 items, so all the rows may not be
full. I need to check to see if all the columns in the used rows have
data in them. I have tried several variations using
SpecialCells(xlCellTypeLastCell) to determine the used range to no
avail. For example,

range(range("b2"),range("range").SpecialCells(xlCe llTypeLastCell)).select

selects B2:H31. Why it goes out to column H I don't know. I set up a
new spreadsheet with a simplified version of my form and it did the
same thing, selecting 2 columns to the right of my last column. I am
not so much interested in why that happened as I am in just being able
to determine the used part of my range

In a nutshell:

I have a range B2:F31
A varying number of rows will have data, the remaining will be blank.
All the blank rows will be at the bottom, all filled rows at the top,
starting with cell b2.
I want to check the range B2:F?? to see if there are any blank cells
using COUNTBLANK or something simlilar. I just can't selct the correct
range.

Can anyone give me any insight? Thanks.



  #3   Report Post  
Posted to microsoft.public.excel.programming
HBS HBS is offline
external usenet poster
 
Posts: 2
Default Selecting used part of a range

I don't want to check every cell in B2:F31. For example, if I input 6
lines of data, I would want to check B2:F7. B8:F31 would be blank.
This could change every time the form is used. I could write some
loops that would cycle through and check, but that seemed overly
complicated.



"Chris Leonard" wrote in message ...


blankcells=0
nonblankcells=0
myRange=Range("B2:F31")
For each c in myRange
if isblank(c.value) then blankcells = blankcells + 1 else nonblankcells
= nonblankcells + 1
Next

Chris

"HBS" wrote in message
om...
I am pretty new to VBA, so this may be obvious, but I can't figue it
out. Like they say, there are no stupid questions, only stupid people
that ask them.

Let me describe my sheet first.

I have a form for data input. There is a column header row in row 1
and a row number column in column A. The data starts in B1, five
columns and 30 rows. I have a named range(called "range")that
references B2:F31. There is no data to the right or below the table.
The data input may be less than 30 items, so all the rows may not be
full. I need to check to see if all the columns in the used rows have
data in them. I have tried several variations using
SpecialCells(xlCellTypeLastCell) to determine the used range to no
avail. For example,

range(range("b2"),range("range").SpecialCells(xlCe llTypeLastCell)).select

selects B2:H31. Why it goes out to column H I don't know. I set up a
new spreadsheet with a simplified version of my form and it did the
same thing, selecting 2 columns to the right of my last column. I am
not so much interested in why that happened as I am in just being able
to determine the used part of my range

In a nutshell:

I have a range B2:F31
A varying number of rows will have data, the remaining will be blank.
All the blank rows will be at the bottom, all filled rows at the top,
starting with cell b2.
I want to check the range B2:F?? to see if there are any blank cells
using COUNTBLANK or something simlilar. I just can't selct the correct
range.

Can anyone give me any insight? Thanks.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default Selecting used part of a range

OK, exit the loop when you get a blank cell then ....

myRange=Range("B2:F31")
For each c in myRange
if isblank(c.value) then
exit for
else
DO SOMETHING
end if
Next


Hope this is what you're after.

Chris

"HBS" wrote in message
om...
I don't want to check every cell in B2:F31. For example, if I input 6
lines of data, I would want to check B2:F7. B8:F31 would be blank.
This could change every time the form is used. I could write some
loops that would cycle through and check, but that seemed overly
complicated.



"Chris Leonard" wrote in message

...


blankcells=0
nonblankcells=0
myRange=Range("B2:F31")
For each c in myRange
if isblank(c.value) then blankcells = blankcells + 1 else

nonblankcells
= nonblankcells + 1
Next

Chris

"HBS" wrote in message
om...
I am pretty new to VBA, so this may be obvious, but I can't figue it
out. Like they say, there are no stupid questions, only stupid people
that ask them.

Let me describe my sheet first.

I have a form for data input. There is a column header row in row 1
and a row number column in column A. The data starts in B1, five
columns and 30 rows. I have a named range(called "range")that
references B2:F31. There is no data to the right or below the table.
The data input may be less than 30 items, so all the rows may not be
full. I need to check to see if all the columns in the used rows have
data in them. I have tried several variations using
SpecialCells(xlCellTypeLastCell) to determine the used range to no
avail. For example,


range(range("b2"),range("range").SpecialCells(xlCe llTypeLastCell)).select

selects B2:H31. Why it goes out to column H I don't know. I set up a
new spreadsheet with a simplified version of my form and it did the
same thing, selecting 2 columns to the right of my last column. I am
not so much interested in why that happened as I am in just being able
to determine the used part of my range

In a nutshell:

I have a range B2:F31
A varying number of rows will have data, the remaining will be blank.
All the blank rows will be at the bottom, all filled rows at the top,
starting with cell b2.
I want to check the range B2:F?? to see if there are any blank cells
using COUNTBLANK or something simlilar. I just can't selct the correct
range.

Can anyone give me any insight? Thanks.



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
Selecting right part of text string Sue Compelling Excel Worksheet Functions 5 November 5th 09 07:54 PM
Selecting part of a number in a cell HRassist Excel Worksheet Functions 1 June 6th 07 08:15 PM
Culling, Or Selecting, Part Of A Number In A Cell Robert11 New Users to Excel 2 November 26th 06 06:39 PM
Selecting the first time a number appears (part 2) Jaydubs Excel Discussion (Misc queries) 2 July 17th 06 02:47 PM
Selecting part of a series for a chart? Al Charts and Charting in Excel 6 May 16th 06 12:45 PM


All times are GMT +1. The time now is 08:16 PM.

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"