Dim c As Range error help

bluefeather8989

Active Member
Joined
Nov 20, 2009
Messages
325
Office Version
  1. 365
Platform
  1. Windows
I have this code in a work sheet thats not working any help on getting it to work.


Rich (BB code):
Private Sub Worksheet_Change(ByVal Target As Range)

    Dim Changed As Range, c As Range
    Set Changed = Intersect(Target, Range("$L$6:$P$69"))
    If Not Changed Is Nothing Then
        Application.EnableEvents = False
        For Each c In Changed
            If c.Value <> "" Then
                c.Value = StrConv(c.Value, vbProperCase)
            End If
        Next c
        Application.EnableEvents = True
    End If
    
    Worksheets("DR").Range("AF2:AF65").Value = Worksheets("1").Range("L6:L69").Value
    
    
    Dim c As Range
Application.ScreenUpdating = False
With Sheets("DR")
  Sheets("DR").Range("O2:U65") = .Range("O2:U65").Value
  For Each c In Sheets("1").Range("R6:R69")
    Sheets("DR").Range("O2:U65").Replace What:=CStr(c), Replacement:="", LookAt:=xlWhole
  Next
End With

    Call Random
End Sub
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
should be CStr(c.Value)
Untitled.png
 
Upvote 0
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)

    Dim Changed As Range, c As Range
    Set Changed = Intersect(Target, Range("$L$6:$P$69"))
    If Not Changed Is Nothing Then
        Application.EnableEvents = False
        For Each c In Changed
            If c.Value <> "" Then
                c.Value = StrConv(c.Value, vbProperCase)
            End If
        Next c
        Application.EnableEvents = True
    End If
    
    Worksheets("DR").Range("AF2:AF65").Value = Worksheets("1").Range("L6:L69").Value
    
    
Application.ScreenUpdating = False
With Sheets("DR")
  Sheets("DR").Range("O2:U65") = .Range("O2:U65").Value
  For Each c In Sheets("1").Range("R6:R69")
    Sheets("DR").Range("O2:U65").Replace What:=CStr(c.Value), Replacement:="", LookAt:=xlWhole
  Next
End With

    Call Random
End Sub
 
Upvote 0
Solution

Forum statistics

Threads
1,216,102
Messages
6,128,853
Members
449,471
Latest member
lachbee

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