Need to add text in existing formula

mdd16

Board Regular
Joined
Jan 11, 2011
Messages
84
Office Version
  1. 365
Platform
  1. Windows
Hi there,

I need some help in my code. I need to add additional components in the existing formula of a cell.. I am able to build string to be added with VBA.

The addition is at place which is 8 characters from behind. Screen shot is attached to show formula with added string and original formula

Any help will be highly appreciated..

MOHAN DHINGRA
 

Attachments

  • Add text to existing formula.jpg
    Add text to existing formula.jpg
    94.9 KB · Views: 10

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
Example for A1 cell:

VBA Code:
Range("A1").Formula = Left(Range("A1").Formula, Len(Range("A1").Formula)-9) & "+RC[22]*RC[23]" & Right(Range("A1").Formula, 9)
 
Upvote 0
Hi .. thanks for your quick response.

I am getting an error when I implemented the suggested code. Attached file shows the error and my steps.

Thanks again for your kind help..
 

Attachments

  • Add text to existing formula 2.jpg
    Add text to existing formula 2.jpg
    113.7 KB · Views: 3
Upvote 0
I don't know your data. Maybe you should try -9 instead of -8. Maybe excel isn't accepting as valid formula.
 
Upvote 0
I don't know your data. Maybe you should try -9 instead of -8. Maybe excel isn't accepting as valid formula.

Hello .. I solved it.. the error was because of range method. I had already set mAncr2 as a range and then I was adding word .. as in... Range(mAncr2) again.

Thanks so much for your help
 
Upvote 0

Forum statistics

Threads
1,214,827
Messages
6,121,817
Members
449,049
Latest member
cybersurfer5000

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top