Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default macro to edit formula

I've been trying, without luck, to get a macro to work that will append a
value to a formula that references a range of cells in my worksheet.

The formula simply copies values from another worksheet into a new
worksheet. I need to multiply the values in a given range of cells in the
new worksheet by a number. I've been doing this manually by selecting a
cell, then editing the formula by hitting Ctrl-V to append the number in the
formula, then I select the next cell, and repeat the edit. I have to do this
hundreds of time.

I know there's a simple way of having a macro do this, but nothing try
seems to work.

Any suggestions would be very much appreciated.

Steve




  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 576
Default macro to edit formula

Steve,
I used the PasteSpecial Multiply function in the following code.

Range("B1") = InputBox("Enter multiplier", "Multiplier")
Range("B1").Copy
Range("A1:A5").PasteSpecial Paste:=xlAll, Operation:=xlMultiply,
SkipBlanks:= _
False, Transpose:=False
Range("B1").ClearContents

B1 can be any cell away from your data. A1:A5 can be modified to any range
you want.

see if this works for you...

sb

"Steve d'Apollonia" wrote in message
...
I've been trying, without luck, to get a macro to work that will append a
value to a formula that references a range of cells in my worksheet.

The formula simply copies values from another worksheet into a new
worksheet. I need to multiply the values in a given range of cells in the
new worksheet by a number. I've been doing this manually by selecting a
cell, then editing the formula by hitting Ctrl-V to append the number in

the
formula, then I select the next cell, and repeat the edit. I have to do

this
hundreds of time.

I know there's a simple way of having a macro do this, but nothing try
seems to work.

Any suggestions would be very much appreciated.

Steve






  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default macro to edit formula


thanks sb...your code almost worked. When I tried to run it, it came
back with the error: "This operation requires the merged cells to be
identically sized."

As a workaround I tried making the multiplier cells away from the data
with the same range as the range of the data defined in the macro. But I
still got the same error message above.

sd



*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default macro to edit formula



That worked, and was much simpler to do since no macro was necessary.
Thanks Tom!

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default macro to edit formula

in a blank cell, put the number

then select that cell and do Edit=Copy

no select your cells with the formula

do Edit=PasteSpecial=Values and Multiply

assume the number is 6

if a cell contained the formula

=Sheet1!A1

after the operation it will contain

=(Sheet1!A1)*6


Regards,
Tom Ogilvy


"Steve d'Apollonia" wrote in message
...
I've been trying, without luck, to get a macro to work that will append a
value to a formula that references a range of cells in my worksheet.

The formula simply copies values from another worksheet into a new
worksheet. I need to multiply the values in a given range of cells in the
new worksheet by a number. I've been doing this manually by selecting a
cell, then editing the formula by hitting Ctrl-V to append the number in

the
formula, then I select the next cell, and repeat the edit. I have to do

this
hundreds of time.

I know there's a simple way of having a macro do this, but nothing try
seems to work.

Any suggestions would be very much appreciated.

Steve








Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Record Macro and Edit Macro options disabled Huzza New Users to Excel 1 March 18th 09 03:55 PM
Help with MACRO to Edit WORKDAY Formula? Wart Excel Discussion (Misc queries) 2 April 25th 08 10:36 PM
Macro to edit formula in cell Steve Vincent Excel Discussion (Misc queries) 3 January 9th 08 12:09 AM
Macro to edit formula Tang123 Excel Discussion (Misc queries) 2 October 6th 05 08:33 PM
How do I edit a formula as part of a macro? Jacob Wood Excel Discussion (Misc queries) 1 January 25th 05 11:02 PM


All times are GMT +1. The time now is 01:11 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"