Results 1 to 10 of 10

How to combine locked cells and forced uppercase separately using range?

Threaded View

  1. #1
    Registered User
    Join Date
    05-26-2021
    Location
    Hong Kong
    MS-Off Ver
    MS 365
    Posts
    13

    How to combine locked cells and forced uppercase separately using range?

    Hi, I am new to VBA and require some help.

    I am able to lock cells for a certain range (below):

    Private Sub Worksheet_Change(ByVal Target As Range)
        Dim xRg As Range
        On Error Resume Next
        Set xRg = Intersect(Range("A1:A10,C1:C10,E1:E10"), Target)
        If xRg Is Nothing Then Exit Sub
        Target.Worksheet.Unprotect Password:="0"
        If xRg.Value <> mStr Then xRg.Locked = True
        Target.Worksheet.Protect Password:="0"
    End Sub
    And also make certain cells to force uppercase on them (below):

    Private Sub Worksheet_Change(ByVal Target As Excel.Range)
    Dim rngCell As Range
        If Intersect(Target, Range("B1:B1O,D1,F1")) Is Nothing Then Exit Sub
        Application.EnableEvents = False
        For Each rngCell In Target.Cells
        rngCell = UCase(rngCell)
        Next
        Application.EnableEvents = True
    End Sub
    And I learnt that there cannot be duplicates of Worksheet_Change but i am having difficulties on how to combine them together. Kindly advise on how to combine them both.
    Have attached the excel document on what i have done also.
    Thank you.
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Forced Calculation of All Cells
    By ffffloyd in forum Excel General
    Replies: 10
    Last Post: 11-06-2014, 08:36 PM
  2. Copy and paste locked cells, and have pasted cells retain LOCKED status.
    By stratloveslenny in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-16-2014, 03:05 PM
  3. Replies: 3
    Last Post: 04-12-2014, 04:47 AM
  4. Unlock only a range of cells on a locked sheet?
    By Margate in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-26-2013, 09:32 AM
  5. Getting the Min for Moving Range with Locked Cells
    By RoxannaBannana in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 01-25-2013, 04:01 PM
  6. Forced input into cells
    By MattGriff in forum Excel General
    Replies: 1
    Last Post: 03-01-2011, 12:00 PM
  7. forced selection of a merged cell range otherwise no action from commandbutton
    By vdongen in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 10-09-2010, 03:23 AM

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