title: CDbl() woes and type mismatch
body: <p>I'm fairly new to VBA and have had some issues with a script I've been tasked to write. What it's supposed to do is to use the semicolon-spaced data in a single cell (the data contains names and numbers inside brackets) and find the names with the biggest numbers then separate that into different cells. </p>
  
  <p>To take out the numbers from string I'm using the custom function ExtractNumber developed by ozgrid: <a href="http://www.ozgrid.com/VBA/ExtractNum.htm" rel="nofollow noreferrer">http://www.ozgrid.com/VBA/ExtractNum.htm</a></p>
  
  <p>I keep getting </p>
  
  <blockquote>
    <p>error 424</p>
  </blockquote>
  
  <p>while trying to call that function, precisely in its last line:</p>
  
  <pre><code>ExtractNumber = CDbl(lNum)
  </code></pre>
  
  <p>Like another user suggested, I tried switching the type of variable here:</p>
  
  <pre><code>ExtractNumber(rCell As String, 
  </code></pre>
  
  <p>but it has not helped at all. I've also tried switching the CDbl() command to any other C...() type command as well as removing it entirely. No luck. I feel like I'm hitting an enormous brick wall, and my time is slowly running out. Could I ask for assistance once more? Here is my full code:</p>
  
  <pre><code>Option Explicit
  
  Sub Divide()
  
  Dim txt As String
  Dim i As Integer
  Dim j As Integer
  Dim Full As Variant
  Dim a As Integer
  Dim b As Integer
  Dim stored() As Integer
  
  txt = (CStr(ActiveCell.Value))
  Full = Split(txt, ";")
  a = UBound(Full)
  b = a - 1
  
  ReDim stored(b)
  
  For i = 0 To a
      stored(i) = ExtractNumber((Full(i)))
  Next i
  
  Dim primary_index As Integer
  Dim primary_no As Integer
  Dim primary_name As String
  primary_index = Application.Match(Application.Max(stored), stored, 0)
  primary_no = stored(primary_index)
  primary_name = Full(primary_index)
  stored(primary_index) = 0
  
  If UBound(stored) &gt; 1 Then
      Dim secondary_index As Integer
      Dim secondary_no As Integer
      Dim secondary_name As String
      secondary_index = Application.Match(Application.Max(stored), stored, 0)
      secondary_no = stored(secondary_index)
      secondary_name = Full(secondary_index)
  End If
  
  For i = 0 To 6
      ActiveCell.EntireColumn.Offset(0, 1).Insert
  Next i
  
  If UBound(stored) &gt; 2 Then
      Dim names() As String
      ReDim names(0 To a)
      For j = 0 To a
          If Not (j = primary_index Or j = secondary_index) Then
              names(j) = Full(j)
          End If
      Next j
  
      ActiveCell.Offset(0, 1).Value = primary_name
      ActiveCell.Offset(0, 2).Value = primary_no
      ActiveCell.Offset(0, 3).Value = secondary_name
      ActiveCell.Offset(0, 4).Value = secondary_no
      ActiveCell.Offset(0, 5).Value = names
      ActiveCell.Offset(0, 6).Value = (ActiveCell.Offset(0, 8).Value - primary_no             - secondary_no)
  
  ElseIf UBound(stored) = 2 Then
      ActiveCell.Offset(0, 1).Value = primary_name
      ActiveCell.Offset(0, 2).Value = primary_no
      ActiveCell.Offset(0, 3).Value = secondary_name
      ActiveCell.Offset(0, 4).Value = secondary_no
  End
  
  Else
      ActiveCell.Offset(0, 1).Value = primary_name
      ActiveCell.Offset(0, 2).Value = primary_no
  End
  
  End If
  End Sub
  </code></pre>
  
  <p>Here's a sample of my data: <a href="https://drive.google.com/file/d/1m4gNqfaU8Z1kbPI3kE35Q7wPxhmZfgNF/view?usp=sharing" rel="nofollow noreferrer">click</a></p>
  
  <p>Example of a cells content:  <code>A&amp;W All American Food (1) ; American Pie Cafe (1) ; Arby's (53) ; Auntie Anne's (13) ; Auntie Anne's Hand-Rolled Soft Pretzels (1) ; Baskin Robbins (1) ; Beef-A-Roo (1) ; Big Steer Restaurant ; Bill Ellis BBQ (1) ; Breakfast/Soup Bar (116) ; Broadway Diner (4) ; Burger King (4) ; Chester's Chicken (2) ; Cinnabon (126) ; Country Market (1) ; Country Skillet (1) ; Cuban Cuisine Restaurant (1) ; Dairy Queen (23) ; Dan's Big Slice Pizza (1) ; Day Breaker's Cafe (1) ; Deli (17) ; Denny's (97) ; Dunkin' Donuts (6) ; Family Restaurant (1) ; Full Service (4) ; Golden Corral (2) ; Gooseberry Farms (1) ; GrandMa Max's (3) ; Hardee's (1) ; Hot Food and Pizza (44) ; Hot Stuff Pizza (3) ; Huddle House (1) ; IHOP Restaurant (1) ; J's Wok and Grill (1) ; Johnny Pastrami (1) ; Junie's Restaurant (1) ; KFC (3) ; Krispy Krunchy Chicken (1) ; Long John Silver's (1) ; Max's Highway Diner (1) ; McDonald's (39) ; Mexican Grill (1) ; Milestone Diner (3) ; Moe's Southwest Grill (6) ; Nathan's Famous (1) ; Noble Roman's Pizza (1) ; Penn 80 Grill (1) ; Pizza Hut (4) ; Pizza Shop (1) ; Q Eats (1) ; Quiznos (2) ; Sam Bass Steakhouse (1) ; Sbarro (1) ; Silver Skillet (1) ; Subway (231) ; Sunshine Cafe (1) ; Taco Bell (8) ; Taco Bell/KFC (1) ; Taco John's (1) ; Wendy's Old Fashioned Hamburgers (72)</code></p>