Solved

Link sheets

Posted on 2016-09-08
13
31 Views
Last Modified: 2016-09-28
Hello I have a little problem.
For example in sheet1 on C13 i have formula like 5.81*0.97 and in the sheet2 in C13 i have formula 888*0.97..
What i need to do to like link them, like if i change that (0.97 to 0.85) in sheet1 in C13 it will automatic change in sheet2 in C13 from 0.97 to 0.85 as well.
???
0
Comment
Question by:Janis Ozols
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 6
13 Comments
 
LVL 52

Expert Comment

by:Ryan Chong
ID: 41789248
>>What i need to do to like link them, like if i change that (0.97 to 0.85) in sheet1 in C13 it will automatic change in sheet2 in C13 from 0.97 to 0.85 as well.
both need to refer to a static cell in order to do that, which mean you need to put the value of 0.85 to another cell, let both C13 in Sheet1 and Sheet2 refer to it.
28968462.xlsx
1
 
LVL 43

Expert Comment

by:Saqib Husain, Syed
ID: 41789256
You can do this using a macro. Do you want to go in that direction?
1
 

Author Comment

by:Janis Ozols
ID: 41789257
I could go that direction it would be really good for me.
0
Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

 
LVL 43

Expert Comment

by:Saqib Husain, Syed
ID: 41789353
Try this macro in the Workbook Module
Option Explicit
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
    If Target.Count = 1 Then
        If ActiveCell.Worksheet.Name = Target.Worksheet.Name Then
            If Sh.Name = "Sheet1" Or Sh.Name = "Sheet2" Then
                If Target.Address = Range("C13").Address Then
                    If Sh.Name = "Sheet1" Then
                        Sheets("Sheet2").Range("C13").Formula = Left(Sheets("Sheet2").Range("C13").Formula, InStr(Sheets("Sheet2").Range("C13").Formula, "*")) & Right(Target.Formula, Len(Target.Formula) - InStr(Target.Formula, "*"))
                    ElseIf Sh.Name = "Sheet2" Then
                        Sheets("Sheet1").Range("C13").Formula = Left(Sheets("Sheet1").Range("C13").Formula, InStr(Sheets("Sheet1").Range("C13").Formula, "*")) & Right(Target.Formula, Len(Target.Formula) - InStr(Target.Formula, "*"))
                    End If
                End If
            End If
        End If
    End If
End Sub

Open in new window

Change-constant-macro.xlsm
1
 

Author Comment

by:Janis Ozols
ID: 41789363
Woow, it really helped, what can I do if range is from C13 to I13, how I need to change the Macros?
0
 
LVL 43

Expert Comment

by:Saqib Husain, Syed
ID: 41789373
Change the macro to
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
    If Target.Count = 1 Then
        If ActiveCell.Worksheet.Name = Target.Worksheet.Name Then
            If Sh.Name = "Sheet1" Or Sh.Name = "Sheet2" Then
                If Not Intersect(Target, Range("C13:I13")) Is Nothing Then
                    If Sh.Name = "Sheet1" Then
                        Sheets("Sheet2").Range(Target.Address).Formula = Left(Sheets("Sheet2").Range(Target.Address).Formula, InStr(Sheets("Sheet2").Range(Target.Address).Formula, "*")) & Right(Target.Formula, Len(Target.Formula) - InStr(Target.Formula, "*"))
                    ElseIf Sh.Name = "Sheet2" Then
                        Sheets("Sheet1").Range(Target.Address).Formula = Left(Sheets("Sheet1").Range(Target.Address).Formula, InStr(Sheets("Sheet1").Range(Target.Address).Formula, "*")) & Right(Target.Formula, Len(Target.Formula) - InStr(Target.Formula, "*"))
                    End If
                End If
            End If
        End If
    End If
End Sub

Open in new window

0
 

Author Comment

by:Janis Ozols
ID: 41789391
This didn't work for me still changes just C13 cells.
0
 

Author Comment

by:Janis Ozols
ID: 41789396
Ohh wait it worked. thanks very mush for help :)
0
 

Author Comment

by:Janis Ozols
ID: 41789406
What would the Macro be if I could change the (0.97) in C13 and it would automatic change from C13 to I13 in sheet1 and sheet2?
0
 
LVL 43

Expert Comment

by:Saqib Husain, Syed
ID: 41789541
Send a sample file.
1
 

Author Comment

by:Janis Ozols
ID: 41790777
Here is the sample file.
aaa.xlsx
0
 
LVL 43

Accepted Solution

by:
Saqib Husain, Syed earned 500 total points (awarded by participants)
ID: 41790814
Public evnt As Boolean
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
Dim cel As Range, sufx As String
If evnt = False Then
    evnt = True
    If Target.Count = 1 Then
        sufx = Right(Target.Formula, Len(Target.Formula) - InStr(Target.Formula, "*"))
        For Each cel In Sheet1.Range("C13:I13")
            cel.Formula = Left(cel.Formula, InStr(cel.Formula, "*")) & sufx
        Next cel
        For Each cel In Sheet2.Range("C13:I13")
            cel.Formula = Left(cel.Formula, InStr(cel.Formula, "*")) & sufx
        Next cel
    End If
    evnt = False
End If
End Sub
0
 
LVL 43

Expert Comment

by:Saqib Husain, Syed
ID: 41819426
Assuming the asker's intent.
0

Featured Post

Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
This article describes a serious pitfall that can happen when deleting shapes using VBA.
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question