Welcome to MacForumz.com!
FAQFAQ      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

visual basic data fill?

 
   Macintosh computer (Home) -> Excel RSS
Next:  Cannot access some excel files  
Author Message
Carrie

External


Since: Jun 25, 2007
Posts: 2



(Msg. 1) Posted: Thu Jan 17, 2008 10:16 am
Post subject: visual basic data fill?
Archived from groups: microsoft>public>mac>office>excel (more info?)

I have a very large range whereas I have 0's, 1's and 2's. The values
represent dates for classes in columns. (Example: Column D represents an
instructor and at some location down the column there is a 1 for start date
and a 2 for an end date. All other cells are 0's. see below)

When the 1 is found, I need all subsequent 0's between the 1 and 2 to be 1's
as well as the 2 to be replaced by a 1.

I cannot figure this out, can anyone help?

0
0
0
0
0
1
0
0
0
0
0
0
0
2
0
0
0
0
0
1
0
0
0
2
0
0
0

 >> Stay informed about: visual basic data fill? 
Back to top
Login to vote
JE McGimpsey

External


Since: Mar 07, 2004
Posts: 3828



(Msg. 2) Posted: Thu Jan 17, 2008 11:46 am
Post subject: Re: visual basic data fill? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

In article <07671D49-6760-48F5-B35E-0D85010E1F05 DeleteThis @microsoft.com>,
Carrie <Carrie DeleteThis @discussions.microsoft.com> wrote:

> I have a very large range whereas I have 0's, 1's and 2's. The values
> represent dates for classes in columns. (Example: Column D represents an
> instructor and at some location down the column there is a 1 for start date
> and a 2 for an end date. All other cells are 0's. see below)
>
> When the 1 is found, I need all subsequent 0's between the 1 and 2 to be 1's
> as well as the 2 to be replaced by a 1.
>
> I cannot figure this out, can anyone help?

One way:

Dim rCell As Range
Dim nVal As Long
For Each rCell In Range("D2:D" & _
Range("D" & Rows.Count).End(xlUp).Row)
With rCell
If .Value = 0 Then
.Value = nVal
Else
nVal = 1 - nVal
End If
End With
Next rCell

 >> Stay informed about: visual basic data fill? 
Back to top
Login to vote
Display posts from previous:   
   Macintosh computer (Home) -> Excel All times are: Pacific Time (US & Canada) (change)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]