+ Reply to Thread
Results 1 to 2 of 2

Combining two Private Sub Worksheet_Change(ByVal Target As Range)

  1. #1
    Registered User
    Join Date
    09-07-2014
    Location
    Australia
    MS-Off Ver
    2010
    Posts
    2

    Combining two Private Sub Worksheet_Change(ByVal Target As Range)

    Hi, I am new to VBA and I have two Private Sub Worksheet_Change(ByVal Target As Range) that work great separately but I don't know how to combine them into one. Any help would be greatly appreciated.

    Here is my two Private Sub Worksheet_Change(ByVal Target As Range):


    Private Sub Worksheet_Change(ByVal Target As Range) 'this macro triggers other macros based on data being entered in to specific cells
    If Target.Address = "$F$4" Then 'triggers HeaderChange Macro below if data entered or changed in cell B5 on the cover page
    Call FontChangeName
    Call Fontsize
    End If
    End Sub

    Sub FontChangeName() 'this macro updates the date in the header throughout the risk assessment based on the Provider Number entered in to cell F5


    Dim rng As Range
    Dim rCell As Range

    Set rng = Range("F26:H39")

    For Each rCell In rng
    If Len(rCell.Text) > 15 Then
    rCell.Font.Size = 6
    Else
    rCell.Font.Size = 9
    End If
    Next



    End Sub

    Sub Fontsize()
    'change font size when number of characters reach past 260
    Dim wCell As Range

    If Union(Target, Range("L10:O21")).Address = _
    Range("L10:O21").Address Then
    Application.EnableEvents = False
    For Each wCell In Target
    If Len(wCell.Text) > 250 Then
    wCell.Font.Size = 7
    Else
    wCell.Font.Size = 9
    End If
    Next
    Application.EnableEvents = True
    End If
    End Sub



    Many thanks in advance.

  2. #2
    Registered User
    Join Date
    09-07-2014
    Location
    Australia
    MS-Off Ver
    2010
    Posts
    2

    Re: Combining two Private Sub Worksheet_Change(ByVal Target As Range)

    Any help is much appreciated.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Combining multiple Private Sub Worksheet_Change(ByVal Target As Range)
    By victortan in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 02-21-2014, 11:12 AM
  2. Private Sub Worksheet_Change(ByVal Target As Range)
    By BigJim68 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 01-27-2014, 01:57 PM
  3. [SOLVED] Private Sub Worksheet_Change(ByVal Target As Range) End Sub
    By kanonathena in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-10-2013, 12:25 AM
  4. Private Sub Worksheet_Change(ByVal Target As Range) Help
    By adamsj1 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-28-2012, 09:17 AM
  5. Private Sub Worksheet_Change(ByVal Target As Range)
    By bondcrash in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-11-2005, 02:59 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1