Pasting Formula While Using Cell Reference in Pasted Cell - excel

I've been given an old calendar workbook.
It has direct cell references to other sheets to fill the spaces in the calendar.
I have been tasked to change these to show TBD when nothing is entered in the secondary sheet(s).
I've got the formula figured out: =IF(REF=" ", "TBD", REF), so a cell which references secondary sheet R, cell A1 would look like =IF(R!$A$1=" ", "TBD", R!$A$1).
However, there are dozens of these cells. Pasting over them overwrites their original cell values, so I was wondering if there was a way to paste in the formula while maintaining not the cell value in the copied cell, but in the destination cell.
Thanks!

Related

Excel: INDIRECT function cell reference will not drag down

So i'm working on a spreadsheet where i need to lookup a value from a tab of which the name is defined in a cell, in this case D7. Using this method i can dynamically search my workbook tabs and select the correct tab and cell reference.
The problem i'm having is that the cell i'm retrieving will not change when i drag down the formula.
=INDIRECT("'"&$D7&"'!S2")
D7 = dynamic tab name
S2 = cell to retrieve... here is where I'm having the problem, this is a value i want to change when i drag down.
Please can someone help here?
You can use the row of the cell with the formula to calculate the row of the referenced cell:
=INDIRECT("'"&$D1&"'!A" & ROW())
note: the above assumes the formula is in the same row as the cell you are referencing (row 2 in your example)

Excel creating additional sheets by copying but keeping formula

I have a workbook (we are using them for electronic purchase orders) and I need to be able to copy a worksheet but have the formula in it increment like it would if I copied the formula in a sheet.
In other words in sheet2 I1 the formula is ='Sheet1'!$I$1+1. When I copy sheet2 and it becomes sheet3, I need the formula in I1 to say ='Sheet2'!$I$1+1.
How can i do this?
You can get a string containing the current sheet name with the following formula
=cell("filename",A1)
If you are using the standard Sheet# for your pages, then you can get the current sheet number with this formula (assuming the previous one was in B3)
=RIGHT(B3,LEN(B3) - FIND("]Sheet",B3,1)-5)
Next calculate the number for the previous sheet
=VALUE(B4)+1
Now you can use the indirect function to address a cell in the previous sheet
=INDIRECT("Sheet"&B5&"!B1")
In Sheet4, this will reference B1 in Sheet3.
Copy it to Sheet5 and it will reference B1 in Sheet 4.

Excel relative cell hyperlink

I have a workbook with sheet1 and sheet 2, sheet1 cell A1 pulls info from sheet2 cell C1, so for easy editing I have hyperlinked sheey2!C1 in sheet1 cell A1.
My issue is that when i delete rows/columbs in sheet 2, the hyperlink does not adapt accordingly and then pull the wrong data, any ways around this?
You can try this to create your hyperlink:
=HYPERLINK(link_location[, friendly_name])
Example:
=HYPERLINK(Sheet2!A2, "A2")
In the given example, if the first row is deleted, the formula is automatically changed to =HYPERLINK(Sheet2!A1, "A2")

Macro to copy and paste as values only the active cells

I am new creating macros and I usually record them but I'm having problems copying and paste as values to remove the formula from 3 highlighted cells
For example I have a formula on cell B3 C3 & H3 so I would like to highlight only those cells manually and then the macro can remove the formula on each like copy and paste as values on the same cells
I have tried with ActiveCell.Select but that only works for 1 cell not for multiple cells and also the problem is that I need to change to values different cells each day
Not sure I follow your question exactly but here is what I think your asking for.
You can loop through each cell that is selected and then set the cell value to it's current value which effectively removes all formulas. There are other ways to do this but I think this best answers your specific question.
Sub removeFormula()
For Each cell In Selection
cell.Value = cell.Value
Next cell
End Sub

copying excel cells one by one and not range at once

I'm developing some excel macros, and now I'm stucked with following,
I want the macro getting the cells from another file and put it on the new one but it is important to consider that copy the full range is not an option, so for example first i Need to copy a1 then a2 , etc ...
the reason is because after each "paste" process, I have to check, the old value and then start a triger of another macro depending on both values, and if ai paste the full range at once it is not working,.
Try getting the Cells value at given row and column from the Worksheet objects you are manipulating.
Example : I want to copye the value (cell content only, not style) from worksheet1 cell A1 to worksheet2 cell B3.
worksheet2.Cells(3, 2).Value = worksheet1.Cells(1, 1).Value
Simple as that.

Resources