+ Reply to Thread
Results 1 to 3 of 3

"Run-time error '13': Type mismatch" when deleteing multiple cells from targeted columns

Hybrid View

  1. #1
    Registered User
    Join Date
    09-26-2012
    Location
    Buffalo
    MS-Off Ver
    Excel 2010
    Posts
    2

    "Run-time error '13': Type mismatch" when deleteing multiple cells from targeted columns

    I'm new to this forum but it looks like the place to be to get help with Macros

    I have the following code that works great, it essentially puts Auto Caps on anything in columns B, F, AA, and DX which is what I want but when I go to delete multiple items in the same row from these columns I get this error: "Run-time error '13': Type mismatch"

    I then select debug and it highlights this line in yellow from my code: Target = UCase(Target)

    Here's my code:
    Private Sub Worksheet_Change(ByVal Target As Range)
      Dim LastRow As Long
      Dim Rng As Range
      Dim StartCell As String
      Dim StartRow As Long
      
        StartCell = "B2"
        
          With Range(StartCell)
            C = .Column
            StartRow = .Row
          End With
          
          LastRow = Cells(Rows.Count, C).End(xlUp).Row
          LastRow = IIf(LastRow < StartRow, StartRow, LastRow)
          Set Rng = Range(Cells(StartRow, C), Cells(LastRow, C))
          
       Application.EnableEvents = False
       
            Select Case Target.Column
              Case 2, 6, 27, 128
                Target = UCase(Target)
              End Select
          
        Application.EnableEvents = True
    End Sub
    Any help would be greatly appreciated!

    Thanks!
    Last edited by JosephP; 09-26-2012 at 12:48 PM. Reason: add code tags

  2. #2
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: "Run-time error '13': Type mismatch" when deleteing multiple cells from targeted colum

    the first part of your code doesn't seem to do anything? why is it there?

    perhaps
    Private Sub Worksheet_Change(ByVal Target As Range)
      Dim Rng As Range
    if not intersect(target, range("B:B,f:F, aa:AA,dx:DX")) is nothing then
       Application.EnableEvents = False
       for each rng in intersect(target, range("B:B,f:F, aa:AA,dx:DX")).cells
                Rng.value = UCase(Rng.value)
       Next rng
          
        Application.EnableEvents = True
       end if
    End Sub
    please note the code tags I added to your post-you need to use them when posting code
    Josie

    if at first you don't succeed try doing it the way your wife told you to

  3. #3
    Registered User
    Join Date
    09-26-2012
    Location
    Buffalo
    MS-Off Ver
    Excel 2010
    Posts
    2

    Re: "Run-time error '13': Type mismatch" when deleteing multiple cells from targeted colum

    Wow. I feel dumb lol.

    This worked to perfection! I don't know what the first part was for...

    Love this site and it's helpful people on it!

    I will start using code tags from here on out and I will mark this as solved.

    Thanks again!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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