×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

VB-ITERATION

VB-ITERATION

VB-ITERATION

(OP)
How do I stop AN iteration when it reaches the end of a group of occupied cells filled with the IDENTICAL text (i.e. B277) in a column?

I want it to stop at the end of the list. HOW does it know that the next
cell is empty so it will not error or use an empty cell.
the length of the list in a column or number of rows varies for different
groups that the routine or loop neet to operate on. thank you for your help.
I know there is a way of doing.


RE: VB-ITERATION

(OP)
I WOULD ALSO LIKE THE SCRIPT TO TELL ME THE NUMBER OF ROWS CONTAINED IN THE GROUP.

THANKS A LOT

RE: VB-ITERATION

Start from the first cell and use a Do Loop, increementing the row counter and checking for the appropriate value:

CODE

Private Sub CommandButton1_Click()
a = 1
Do While ActiveSheet.Cells(a, 1) = "b277"
Cells(a, 2) = a ' or do whatever you need here
a = a + 1
Loop
MsgBox a - 1 & " Cells affected"
End Sub

The example starts looking at A1 and goes down until the cell value changes. Change the initial value of a to start at a different row. The second value in the first Cells function (1 in this case) sets the column to search

Good Luck
johnwm
________________________________________________________
To get the best from these forums read FAQ731-376 before posting

UK steam enthusiasts: www.essexsteam.co.uk

RE: VB-ITERATION

(OP)
thanks johnwm,
it worked good

RE: VB-ITERATION

As fasr as i know you just put it inside a whiloe loop with a <>EOF command!

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources