PC Review


Reply
Thread Tools Rate Thread

Change data value in a range of cells

 
 
=?Utf-8?B?dHVyZW4=?=
Guest
Posts: n/a
 
      4th Sep 2007
I want to convert data value in a range of cells according to a specified
rule. For example, To divide the value in each cell by the value in the
first cell (row) in each column and multiply by 100.

1 2 100 100
2 3 200 150
3 4 To 300 200
4 5 400 250
5 6 500 300

If I enter formula for each cell one by one, it will be a very laboring
process. It seems there should be a simpler way to do this. Can someone
please help me? Thank you very much.
 
Reply With Quote
 
 
 
 
=?Utf-8?B?QmFyYiBSZWluaGFyZHQ=?=
Guest
Posts: n/a
 
      5th Sep 2007
Try entering your formula in the top cell of the range. You should then
see a little black box in the lower right hand corner of the cell. Click on
that and drag down as far as necessary.

HTH,
Barb Reinhardt



"turen" wrote:

> I want to convert data value in a range of cells according to a specified
> rule. For example, To divide the value in each cell by the value in the
> first cell (row) in each column and multiply by 100.
>
> 1 2 100 100
> 2 3 200 150
> 3 4 To 300 200
> 4 5 400 250
> 5 6 500 300
>
> If I enter formula for each cell one by one, it will be a very laboring
> process. It seems there should be a simpler way to do this. Can someone
> please help me? Thank you very much.

 
Reply With Quote
 
=?Utf-8?B?dHVyZW4=?=
Guest
Posts: n/a
 
      5th Sep 2007
Thanks for the reply. But this will only give me the same value as that in
the top cell. It seems I need to write a VB Script to select a range of
cells and then divide the value in each cell by certain value. hope someone
can tell me how to do that.

"Barb Reinhardt" wrote:

> Try entering your formula in the top cell of the range. You should then
> see a little black box in the lower right hand corner of the cell. Click on
> that and drag down as far as necessary.
>
> HTH,
> Barb Reinhardt
>
>
>
> "turen" wrote:
>
> > I want to convert data value in a range of cells according to a specified
> > rule. For example, To divide the value in each cell by the value in the
> > first cell (row) in each column and multiply by 100.
> >
> > 1 2 100 100
> > 2 3 200 150
> > 3 4 To 300 200
> > 4 5 400 250
> > 5 6 500 300
> >
> > If I enter formula for each cell one by one, it will be a very laboring
> > process. It seems there should be a simpler way to do this. Can someone
> > please help me? Thank you very much.

 
Reply With Quote
 
=?Utf-8?B?SGFsaW0=?=
Guest
Posts: n/a
 
      5th Sep 2007
I hope my post will give your correct query:

Sub test()
Dim r, c
For c = 1 To 2
For r = 1 To 5
If c = 1 Then
Cells(r, c) = r
Cells(r, c).Offset(0, 2) = _
Cells(r, c) * 100
ElseIf c = 2 Then
Cells(r, c) = r + 1
Cells(r, c).Offset(0, 2) = _
Cells(r, c) * 50
End If
Next r
Next c
End Sub

--
Regards,

Halim



"turen" wrote:

> Thanks for the reply. But this will only give me the same value as that in
> the top cell. It seems I need to write a VB Script to select a range of
> cells and then divide the value in each cell by certain value. hope someone
> can tell me how to do that.
>
> "Barb Reinhardt" wrote:
>
> > Try entering your formula in the top cell of the range. You should then
> > see a little black box in the lower right hand corner of the cell. Click on
> > that and drag down as far as necessary.
> >
> > HTH,
> > Barb Reinhardt
> >
> >
> >
> > "turen" wrote:
> >
> > > I want to convert data value in a range of cells according to a specified
> > > rule. For example, To divide the value in each cell by the value in the
> > > first cell (row) in each column and multiply by 100.
> > >
> > > 1 2 100 100
> > > 2 3 200 150
> > > 3 4 To 300 200
> > > 4 5 400 250
> > > 5 6 500 300
> > >
> > > If I enter formula for each cell one by one, it will be a very laboring
> > > process. It seems there should be a simpler way to do this. Can someone
> > > please help me? Thank you very much.

 
Reply With Quote
 
Tim Williams
Guest
Posts: n/a
 
      5th Sep 2007
Select your dataset and run this

'*****************
Sub Tester()

Dim col As Range, c As Range
Dim v

For Each col In Selection.Columns
v = col.Cells(1).Value
For Each c In col.Cells
c.Value = (c.Value / v) * 100
Next c
Next col

End Sub
'*****************

Tim

"turen" <(E-Mail Removed)> wrote in message
news:A8D0276D-BF65-4059-9BFF-(E-Mail Removed)...
>I want to convert data value in a range of cells according to a specified
> rule. For example, To divide the value in each cell by the value in the
> first cell (row) in each column and multiply by 100.
>
> 1 2 100 100
> 2 3 200 150
> 3 4 To 300 200
> 4 5 400 250
> 5 6 500 300
>
> If I enter formula for each cell one by one, it will be a very laboring
> process. It seems there should be a simpler way to do this. Can someone
> please help me? Thank you very much.



 
Reply With Quote
 
=?Utf-8?B?dHVyZW4=?=
Guest
Posts: n/a
 
      5th Sep 2007
Thank you very much, Tim. It works perfectly. Thank you all for taking time
to reply.

Turen

"Tim Williams" wrote:

> Select your dataset and run this
>
> '*****************
> Sub Tester()
>
> Dim col As Range, c As Range
> Dim v
>
> For Each col In Selection.Columns
> v = col.Cells(1).Value
> For Each c In col.Cells
> c.Value = (c.Value / v) * 100
> Next c
> Next col
>
> End Sub
> '*****************
>
> Tim
>
> "turen" <(E-Mail Removed)> wrote in message
> news:A8D0276D-BF65-4059-9BFF-(E-Mail Removed)...
> >I want to convert data value in a range of cells according to a specified
> > rule. For example, To divide the value in each cell by the value in the
> > first cell (row) in each column and multiply by 100.
> >
> > 1 2 100 100
> > 2 3 200 150
> > 3 4 To 300 200
> > 4 5 400 250
> > 5 6 500 300
> >
> > If I enter formula for each cell one by one, it will be a very laboring
> > process. It seems there should be a simpler way to do this. Can someone
> > please help me? Thank you very much.

>
>
>

 
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
change colors in a range of excel cells based on another range of cells Bobbi Muck Microsoft Excel Programming 1 9th Apr 2010 03:47 AM
highlight range, apply calculation to data in cells and paste special to same range S Himmelrich Microsoft Excel Discussion 2 6th Nov 2007 11:48 PM
When entering data into a range of cells, select the entire range. =?Utf-8?B?UQ==?= Microsoft Excel Misc 0 26th Sep 2007 04:36 AM
posted data in a range of cells can't change after three days =?Utf-8?B?YW5keWNhcHA=?= Microsoft Excel Programming 1 18th Mar 2006 01:25 PM
Copy cells into range of cells until cell change =?Utf-8?B?bWRlYW5kYQ==?= Microsoft Excel Worksheet Functions 1 22nd Apr 2005 08:41 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:49 PM.