Cell formula reference to another worksheet cell with macro update

fbk

New Member
Joined
May 24, 2021
Messages
4
Office Version
  1. 365
  2. 2019
  3. 2016
  4. 2013
Platform
  1. Windows
Hello,

i have an excel file with 2 worksheets:
Worksheet A has a cell with formula reference reading from a cell on work sheet B.
There is a macro on the file, the macro will import data from another file into worksheet B.
The issue is i am getting error on Cell formula of worksheet A: #REF!

Kindly advise

Regards,
FBK
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
this is the formula:

1621842087944.png



and this is the macro:

1621842007286.png
 
Upvote 0
Your formula is refering to cell C2 and you are deleting the cells in row 2, hense the #REF error.
replace the C2 in your formula with INDEX(C:C,2,1)
 
Upvote 0
thank you for your reply.
however when i run the macro, excel update the formula from the following:
1621845306971.png

to the following:
1621845353573.png
 
Upvote 0
Another option would be to have the macro put the formula in the cell after you've moved everything around.
 
Upvote 0
am trying to replicate your idea using the following macro, but it didnt work:
Sub Macro1()
'
' Macro1 Macro
'

'
Dim sht As Worksheet
Dim PROJECTAIN As String
Dim PROJECTAIN2 As String
Set sht = Sheets("PROJECTA_Out")

For i = 2 To 10
Columns("E:E").Select
PROEJCTAIN = "(PROJECTA_In!C" & i & ")"
PROJECTAIN2 = "(INDEX(PROJECTA_In!C:C," & i & ",1)"
sht.Cells.Replace What:=PROJECTAIN, Replacement:=PROJECTAIN2, _
LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False, _
SearchFormat:=False, ReplaceFormat:=False

Next i



End Sub
 
Upvote 0

Forum statistics

Threads
1,214,585
Messages
6,120,399
Members
448,958
Latest member
Hat4Life

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