New Excel Forum

This forum has been moved to TeachExcel.com

Ask all future questions in the New Excel Forum.

ExcelKey

Is there a way to delete and insert $ into a formula

Macros, VBA, Excel Automation, etc.

Is there a way to delete and insert $ into a formula

Postby EXCELEXCEL » Sun Nov 15, 2015 5:51 am

I am a building a database. I need to remove $ from one part of a formula and add $ to another part of a formula.

I need to do this same action over and over again for the formula to calculate with the correct references?

How would one build this?

For example,

=PITimeDat(worksheet1!DY4,worksheet1!$A$5,"pi3","interpolated")

needs to become

=PITimeDat(worksheet1!$DY$4,worksheet1!A5,"pi3","interpolated")

The DY4 becomes fixed and A5 becomes unfixed.

Thank you in advance.
  • 0

EXCELEXCEL
Rookie
 
Posts: 3
Joined: Nov 15, 2015
Reputation: 0
Excel Version: 2010

Re: Is there a way to delete and insert $ into a formula

Postby EXCELEXCEL » Sun Nov 15, 2015 6:19 am

If there is a way to do this in one cell and then just repeat the action when clicking the next cell, that would also be just fine.
  • 0

EXCELEXCEL
Rookie
 
Posts: 3
Joined: Nov 15, 2015
Reputation: 0
Excel Version: 2010

Re: Is there a way to delete and insert $ into a formula

Postby EXCELEXCEL » Sun Nov 15, 2015 7:25 am

Without learning too much VB, I see that you can go to the developer window (excel 2010). Record a macro with "use relative references" and this will repeat the actions that you need to perform over and over.
  • 0

EXCELEXCEL
Rookie
 
Posts: 3
Joined: Nov 15, 2015
Reputation: 0
Excel Version: 2010

Re: Is there a way to delete and insert $ into a formula

Postby NoSparks » Sun Nov 15, 2015 2:55 pm

If your database is formatted as a table, all you need do is alter the formula in the first row and Excel will automatically change the rest of the column.

If you really need to go the VBA route to copy the formula to cells,
type the formula you want into the first cell as per normal, hit Enter, then select the cell with the formula you just entered, go to the VBA environment immediate window and type
Code: Select all
? activecell.FormulaR1C1
What gets displayed will be what needs to be written to all the cells you want the formula copied to but... any quote marks will need to be doubled up.
  • 0

NoSparks
Excel Hobbyist
 
Posts: 637
Joined: May 28, 2014
Reputation: 103
Excel Version: 2010


Return to Macros and VBA Questions

Who is online

Users browsing this forum: Google [Bot] and 205 guests