• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

How can I merge two codes together to run as one

How can I merge two codes together to run as one.

What I want is I have a sheet renamed as "Dashboard", I want code 1 to do its work of aligning my charts at the same time formula bar to hide on ONLY that sheet.

Formula bar to be visible on all other sheets.


Code 1

>>> use code - tags <<<
Code:
Private Sub worksheet_Activate()
  
  
    With ActiveSheet.Shapes("chart 4")
        .Left = Range("C3").Left
        .Top = Range("C3").Top
    End With
  
    With ActiveSheet.Shapes("chart 5")
        .Left = Range("E3").Left
        .Top = Range("E3").Top
    End With
   
    With ActiveSheet.Shapes("chart 20")
        .Left = Range("G3").Left
        .Top = Range("G3").Top
    End With
   
    'With ActiveSheet.Shapes("chart 3")
     '   .Left = Range("C5").Left
      '  .Top = Range("C5").Top
    'End With
       
    'With ActiveSheet.Shapes("chart 6")
     '   .Left = Range("E5").Left
      '  .Top = Range("E5").Top
    'End With
       
    'With ActiveSheet.Shapes("chart 11")
     '   .Left = Range("C7").Left
     '   .Top = Range("C7").Top
    'End With
       
    'With ActiveSheet.Shapes("chart 15")
     '   .Left = Range("E7").Left
      '  .Top = Range("E7").Top
    'End With
       
    With ActiveSheet.Shapes("chart 2")
        .Left = Range("I3").Left
        .Top = Range("I3").Top
    End With
   
   
End Sub
**************************************************************************************************************************************
Code 2

Sub Workbook_SheetActivate(ByVal Sh As Object)

    If Sh.Name = "Dashboard" Then
        Application.DisplayFormulaBar = False
    Else
        Application.DisplayFormulaBar = True
    End If


End Sub
 
Last edited by a moderator:
Noneed to merge them.
Put this code in the ThisWorkbook section.
Code:
Private Sub Workbook_SheetActivate(ByVal Sh As Object)
If Sh.Name = "Dashboard" Then
    Application.DisplayFormulaBar = False
Else
    Application.DisplayFormulaBar = True
End If
End Sub
 
Noneed to merge them.
Put this code in the ThisWorkbook section.
Code:
Private Sub Workbook_SheetActivate(ByVal Sh As Object)
If Sh.Name = "Dashboard" Then
    Application.DisplayFormulaBar = False
Else
    Application.DisplayFormulaBar = True
End If
End Sub

Hi Belleke,
The problem that I am facing is when I create a module and paste it in there, it popups up a screen to add the name of the macro, when I add a new name to it, it creates a new one and when I edit it... it disappears and the code doesnt work :(.

I have attached a file for your easy reference.
 

Attachments

  • Pursuits_Tracker_v0.4 (1).xlsm
    203.2 KB · Views: 1
Last edited:
You did put the code in a module not in the ThisWorkbook module like a told you.
See example.
 

Attachments

  • Pursuits_Tracker_v0.4 (1).xlsm
    209.1 KB · Views: 1
Back
Top