PC Review


Reply
Thread Tools Rate Thread

Code to Alter value by adding 1 to value in cell 4 rows above

 
 
Corey
Guest
Posts: n/a
 
      27th Nov 2006
I have some rather involved code that i want to add a stpe to.
I want to have the worksheet to always check to see that betwen cells
(A24:A280), but not all cells between only every 4th cell.
IE. A24,A28,A32 etc.
I want a code to make sure, in the instance that i delete rows between say
A28:A31, then i want to he code to look at the last value in the range(say
A24),
and add 1 to the value and place it in cell A32.

Example:
A24 = 1
A28 = 2
A32 = 3
A36 = 4

If i delete the rows from A28:A31.
A32 needs to change from a value of "3" to a value of "2",
and A36 from 4 to 3 etc....
which is 1 more than the previous.
Hope i am explaining this clearly.
Any idea's?
Corey....


 
Reply With Quote
 
 
 
 
=?Utf-8?B?SkxHV2hpeg==?=
Guest
Posts: n/a
 
      27th Nov 2006
Untested, but something like this. You can put it in a For each ws Next loop.

If LCase(Right(Worksheet.name,1)) <> "c" then
'Do something
End If

"Corey" wrote:

> I have some rather involved code that i want to add a stpe to.
> I want to have the worksheet to always check to see that betwen cells
> (A24:A280), but not all cells between only every 4th cell.
> IE. A24,A28,A32 etc.
> I want a code to make sure, in the instance that i delete rows between say
> A28:A31, then i want to he code to look at the last value in the range(say
> A24),
> and add 1 to the value and place it in cell A32.
>
> Example:
> A24 = 1
> A28 = 2
> A32 = 3
> A36 = 4
>
> If i delete the rows from A28:A31.
> A32 needs to change from a value of "3" to a value of "2",
> and A36 from 4 to 3 etc....
> which is 1 more than the previous.
> Hope i am explaining this clearly.
> Any idea's?
> Corey....
>
>
>

 
Reply With Quote
 
=?Utf-8?B?SkxHV2hpeg==?=
Guest
Posts: n/a
 
      27th Nov 2006
Corey, I just want to see if I understand what you are after. First of all,
it is understood that if you delete A28:A31 the old A32 becomes A28 and the
same with any other rows that are deleted, the next row after the deleted
series will become the row number of the first row of the deleted series.
With that understanding, you then want to maintain a consecutive series from
1 to Ubound for the remaining every fourth cell in column "A". Have I
covered it?

"Corey" wrote:

> I have some rather involved code that i want to add a stpe to.
> I want to have the worksheet to always check to see that betwen cells
> (A24:A280), but not all cells between only every 4th cell.
> IE. A24,A28,A32 etc.
> I want a code to make sure, in the instance that i delete rows between say
> A28:A31, then i want to he code to look at the last value in the range(say
> A24),
> and add 1 to the value and place it in cell A32.
>
> Example:
> A24 = 1
> A28 = 2
> A32 = 3
> A36 = 4
>
> If i delete the rows from A28:A31.
> A32 needs to change from a value of "3" to a value of "2",
> and A36 from 4 to 3 etc....
> which is 1 more than the previous.
> Hope i am explaining this clearly.
> Any idea's?
> Corey....
>
>
>

 
Reply With Quote
 
=?Utf-8?B?SkxHV2hpeg==?=
Guest
Posts: n/a
 
      27th Nov 2006
Corey, disregard the If Lcase(.... posting. That was for a different thread.
I somehow clicked your thread by mistake.

"JLGWhiz" wrote:

> Untested, but something like this. You can put it in a For each ws Next loop.
>
> If LCase(Right(Worksheet.name,1)) <> "c" then
> 'Do something
> End If
>
> "Corey" wrote:
>
> > I have some rather involved code that i want to add a stpe to.
> > I want to have the worksheet to always check to see that betwen cells
> > (A24:A280), but not all cells between only every 4th cell.
> > IE. A24,A28,A32 etc.
> > I want a code to make sure, in the instance that i delete rows between say
> > A28:A31, then i want to he code to look at the last value in the range(say
> > A24),
> > and add 1 to the value and place it in cell A32.
> >
> > Example:
> > A24 = 1
> > A28 = 2
> > A32 = 3
> > A36 = 4
> >
> > If i delete the rows from A28:A31.
> > A32 needs to change from a value of "3" to a value of "2",
> > and A36 from 4 to 3 etc....
> > which is 1 more than the previous.
> > Hope i am explaining this clearly.
> > Any idea's?
> > Corey....
> >
> >
> >

 
Reply With Quote
 
Corey
Guest
Posts: n/a
 
      27th Nov 2006
thanks for the reply.
My goal is to have each of the 4th cell values in sequencial order.

If i need to delete some rows i want the values in each 4th cell to adust
accordingly.
At present if i delete rows, i then need to (depending what rows) manually
adust the values to be in sequence with the one above the deleted rows.

My thinking would be something like:

dim rng as Range
set rng = array.Range(A24,A32,A36......A280)
If Previous previous rng value <>"", then previous rng.value +1
next


Corey....



"JLGWhiz" <(E-Mail Removed)> wrote in message
news:687B31E0-AE1E-4BBD-A902-(E-Mail Removed)...
> Corey, I just want to see if I understand what you are after. First of
> all,
> it is understood that if you delete A28:A31 the old A32 becomes A28 and
> the
> same with any other rows that are deleted, the next row after the deleted
> series will become the row number of the first row of the deleted series.
> With that understanding, you then want to maintain a consecutive series
> from
> 1 to Ubound for the remaining every fourth cell in column "A". Have I
> covered it?
>
> "Corey" wrote:
>
>> I have some rather involved code that i want to add a stpe to.
>> I want to have the worksheet to always check to see that betwen cells
>> (A24:A280), but not all cells between only every 4th cell.
>> IE. A24,A28,A32 etc.
>> I want a code to make sure, in the instance that i delete rows between
>> say
>> A28:A31, then i want to he code to look at the last value in the
>> range(say
>> A24),
>> and add 1 to the value and place it in cell A32.
>>
>> Example:
>> A24 = 1
>> A28 = 2
>> A32 = 3
>> A36 = 4
>>
>> If i delete the rows from A28:A31.
>> A32 needs to change from a value of "3" to a value of "2",
>> and A36 from 4 to 3 etc....
>> which is 1 more than the previous.
>> Hope i am explaining this clearly.
>> Any idea's?
>> Corey....
>>
>>
>>



 
Reply With Quote
 
=?Utf-8?B?SkxHV2hpeg==?=
Guest
Posts: n/a
 
      28th Nov 2006
I think you are on the right track. Otherwise, all I can think of is one
complex If...Then statement. Assigning those rows to an array should work
fine since they automatically renumber themselves when you delete rows. Just
make sure you tell your array to start at 1 instead of zero.

"Corey" wrote:

> thanks for the reply.
> My goal is to have each of the 4th cell values in sequencial order.
>
> If i need to delete some rows i want the values in each 4th cell to adust
> accordingly.
> At present if i delete rows, i then need to (depending what rows) manually
> adust the values to be in sequence with the one above the deleted rows.
>
> My thinking would be something like:
>
> dim rng as Range
> set rng = array.Range(A24,A32,A36......A280)
> If Previous previous rng value <>"", then previous rng.value +1
> next
>
>
> Corey....
>
>
>
> "JLGWhiz" <(E-Mail Removed)> wrote in message
> news:687B31E0-AE1E-4BBD-A902-(E-Mail Removed)...
> > Corey, I just want to see if I understand what you are after. First of
> > all,
> > it is understood that if you delete A28:A31 the old A32 becomes A28 and
> > the
> > same with any other rows that are deleted, the next row after the deleted
> > series will become the row number of the first row of the deleted series.
> > With that understanding, you then want to maintain a consecutive series
> > from
> > 1 to Ubound for the remaining every fourth cell in column "A". Have I
> > covered it?
> >
> > "Corey" wrote:
> >
> >> I have some rather involved code that i want to add a stpe to.
> >> I want to have the worksheet to always check to see that betwen cells
> >> (A24:A280), but not all cells between only every 4th cell.
> >> IE. A24,A28,A32 etc.
> >> I want a code to make sure, in the instance that i delete rows between
> >> say
> >> A28:A31, then i want to he code to look at the last value in the
> >> range(say
> >> A24),
> >> and add 1 to the value and place it in cell A32.
> >>
> >> Example:
> >> A24 = 1
> >> A28 = 2
> >> A32 = 3
> >> A36 = 4
> >>
> >> If i delete the rows from A28:A31.
> >> A32 needs to change from a value of "3" to a value of "2",
> >> and A36 from 4 to 3 etc....
> >> which is 1 more than the previous.
> >> Hope i am explaining this clearly.
> >> Any idea's?
> >> Corey....
> >>
> >>
> >>

>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Start adding blank rows at row 4 (vba code) Pierre Microsoft Excel Worksheet Functions 4 26th Jul 2010 02:00 AM
adding lines of code to a macro to delete rows childofthe1980s Microsoft Excel Programming 11 27th Dec 2009 07:23 AM
How to alter the code to copy to the same exact cell destination? Adnan Microsoft Excel Programming 1 7th Aug 2008 06:30 AM
adding rows depending on cell value Esradekan@gmail.com Microsoft Excel Worksheet Functions 1 18th Feb 2007 04:18 PM
How do I fix cell refs when adding rows =?Utf-8?B?RGF2ZSBM?= Microsoft Excel Misc 5 2nd Dec 2005 09:52 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:12 PM.