add some vba in exiting vba code

Jagat Pavasia

Active Member
Joined
Mar 9, 2015
Messages
406
Office Version
  1. 2021
Platform
  1. Windows
dear sir,
I have VBA code in my excel file and it is working as i want.
Now I want to add vba to all word capital in my B6:B5000, something like Target = UCase(t)


Please add this vba code in below exiting VBA,
I am a new in Excel VBA code user.



The exiting VBA code is Below :

VBA Code:
Private Sub ComboBox1_Change()
ActiveSheet.Range("C1").Select
ActiveSheet.Range("C2").Select
End Sub



Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
If Selection.Row >= 6 Then
Set rng1 = Range(Cells(Selection.Row, 1), Cells(Selection.Row, 7))
Set rng2 = Range(Cells(Selection.Row, 10), Cells(Selection.Row, 12))
Set rng = Union(rng1, rng2)
Static xRow

If xRow <> "" Then
        Range(Cells(xRow, 1), Cells(xRow, 7)).Interior.ColorIndex = xlNone
        Range(Cells(xRow, 10), Cells(xRow, 12)).Interior.ColorIndex = xlNone
End If
prow = Selection.Row
xRow = prow

With rng.Interior
    .ColorIndex = 34
    .Pattern = xlSolid
End With
Else
If xRow <> "" Then
        Range(Cells(xRow, 1), Cells(xRow, 7)).Interior.ColorIndex = xlNone
        Range(Cells(xRow, 10), Cells(xRow, 12)).Interior.ColorIndex = xlNone
End If
End If
End Sub




Private Sub worksheet_change(ByVal Target As Range)
Dim rng As Range
 
  If Target.Count > 1 Then Exit Sub
  Application.EnableEvents = False
  ActiveSheet.Unprotect
  Set rng = Range("C:C,J:J")
  If Not Intersect(Target, rng) Is Nothing Then
    If Target.Value = "**" Then Target.Value = Format(Date, "mm/dd/yyyy")
  End If

  If Not Intersect(Target, Range("A4:O4")) Is Nothing Then
      If Target.Value = "" Then
          ActiveSheet.Range("A6:O6").AutoFilter Field:=Target.Column
      Else
          ActiveSheet.Range("A6:O6").AutoFilter Field:=Target.Column, Operator:=xlFilterValues, Criteria1:=CStr(Target.Value)
      End If
  End If
  ActiveSheet.Protect DrawingObjects:=False, Contents:=True, Scenarios:= _
        False, AllowFormattingCells:=True, AllowFiltering:=True
  Application.EnableEvents = True
End Sub
 
Last edited by a moderator:

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
Add to the Worksheet_Change(ByVal Target As Range) sub line:
VBA Code:
If Not Intersect(Target, Range("B6:B5000")) Is Nothing Then Target.Value = UCase(Target.Value)
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,171
Members
453,021
Latest member
Justyna P

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