PC Review


Reply
Thread Tools Rate Thread

Edit Cell with "/2"

 
 
MikeF
Guest
Posts: n/a
 
      26th Nov 2008
Once subtotals are initiated, can navigate to a GrandTotal cell [know how to
do that] but then ...

Have VBA edit that cell adding "/2" to the end of it ... effectively
dividing it by 2 ... whichever cell it ends up being, which is frequently a
different row.

Have been able to accomplish that, but only with a fixed cell address.

Any assistance will be sincerely appreciated.

-Mike
 
Reply With Quote
 
 
 
 
Michael
Guest
Posts: n/a
 
      26th Nov 2008
Assuming your Grand total is in Column D

In your code do this:
Dim iLastRow as integer

iLastRow=Range("D65536").end(xlup).row
This will provide you a dynamic Last Row Cell Reference, then you can
substitute your fixed cell reference to something like:

Range("D"& iLastRow).value = "=" & Range("D" &ILastRow).value & "/2"
--
If this posting was helpful, please click on the Yes button.
Regards,

Michael Arch.




"MikeF" wrote:

> Once subtotals are initiated, can navigate to a GrandTotal cell [know how to
> do that] but then ...
>
> Have VBA edit that cell adding "/2" to the end of it ... effectively
> dividing it by 2 ... whichever cell it ends up being, which is frequently a
> different row.
>
> Have been able to accomplish that, but only with a fixed cell address.
>
> Any assistance will be sincerely appreciated.
>
> -Mike

 
Reply With Quote
 
Rick Rothstein
Guest
Posts: n/a
 
      26th Nov 2008
I'm not completely sure what you meant by "once subtotals are initiated".
What is in your GrandTotal cell... a value or a formula?

If a value, try this subroutine (after selecting the GrandTotal cell)...

Sub HalfValue()
ActiveCell.Value = ActiveCell.Value / 2
End Sub

If a formula, try this (again, after selecting the GrandTotal cell)...

Sub HalfFormula()
ActiveCell.Formula = ActiveCell.Formula & "/2"
End Sub

If something else, then please describe your situation in more detail.

--
Rick (MVP - Excel)


"MikeF" <(E-Mail Removed)> wrote in message
news:4050790B-4D75-4618-A98F-(E-Mail Removed)...
> Once subtotals are initiated, can navigate to a GrandTotal cell [know how
> to
> do that] but then ...
>
> Have VBA edit that cell adding "/2" to the end of it ... effectively
> dividing it by 2 ... whichever cell it ends up being, which is frequently
> a
> different row.
>
> Have been able to accomplish that, but only with a fixed cell address.
>
> Any assistance will be sincerely appreciated.
>
> -Mike


 
Reply With Quote
 
JLGWhiz
Guest
Posts: n/a
 
      26th Nov 2008
You would probably have to use a relative reference to some point that you
know for sure, or a named reference. Look in VBA help under Referring to
Cells Relative to Other Cells and How to Reference Cells and Ranges. There
are illustrations in both these help files that can give you some ideas on
how to do it.
"MikeF" wrote:

> Once subtotals are initiated, can navigate to a GrandTotal cell [know how to
> do that] but then ...
>
> Have VBA edit that cell adding "/2" to the end of it ... effectively
> dividing it by 2 ... whichever cell it ends up being, which is frequently a
> different row.
>
> Have been able to accomplish that, but only with a fixed cell address.
>
> Any assistance will be sincerely appreciated.
>
> -Mike

 
Reply With Quote
 
MikeF
Guest
Posts: n/a
 
      26th Nov 2008

Rick,

The Sub HalfFormula() worked great.
Thank you, and to all other replies!!

- Mike


"Rick Rothstein" wrote:

> I'm not completely sure what you meant by "once subtotals are initiated".
> What is in your GrandTotal cell... a value or a formula?
>
> If a value, try this subroutine (after selecting the GrandTotal cell)...
>
> Sub HalfValue()
> ActiveCell.Value = ActiveCell.Value / 2
> End Sub
>
> If a formula, try this (again, after selecting the GrandTotal cell)...
>
> Sub HalfFormula()
> ActiveCell.Formula = ActiveCell.Formula & "/2"
> End Sub
>
> If something else, then please describe your situation in more detail.
>
> --
> Rick (MVP - Excel)
>
>
> "MikeF" <(E-Mail Removed)> wrote in message
> news:4050790B-4D75-4618-A98F-(E-Mail Removed)...
> > Once subtotals are initiated, can navigate to a GrandTotal cell [know how
> > to
> > do that] but then ...
> >
> > Have VBA edit that cell adding "/2" to the end of it ... effectively
> > dividing it by 2 ... whichever cell it ends up being, which is frequently
> > a
> > different row.
> >
> > Have been able to accomplish that, but only with a fixed cell address.
> >
> > Any assistance will be sincerely appreciated.
> >
> > -Mike

>
>

 
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
Adding commands to "Folder Options/Edit File Type/Actions" grayed-out "Edit" & "Remove" Green_XP Windows XP Basics 1 6th Nov 2007 08:48 AM
Adding commands to "Folder Options/Edit File Type/Actions" grayed-out "Edit" & "Remove" Green_XP Windows XP Customization 1 6th Nov 2007 08:48 AM
Adding commands to "Folder Options/Edit File Type/Actions" grayed-out "Edit" & "Remove" Green_XP Windows XP General 1 6th Nov 2007 08:48 AM
Adding commands to "Folder Options/Edit File Type/Actions" grayed-out "Edit" & "Remove" Green_XP Windows XP Help 1 6th Nov 2007 08:48 AM
Adding commands to "Folder Options/Edit File Type/Actions" grayed-out "Edit" & "Remove" Green_XP Windows XP New Users 1 6th Nov 2007 08:48 AM


Features
 

Advertising
 

Newsgroups
 


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