VBA - Error 13 - Type mismatch

paul11

New Member
Joined
Dec 30, 2012
Messages
2
Hi,

I have this macro which looks for the unit 'ps' in Column Y and multiplies 1E+12 with the corresponding data in column AC. When it tries to multiply 1E+12, it throws a type mismatch error.

Below is the code.

Code:
Sub Multiply_Tdata()
'
' Change the value of the data (AC) column - multiply by 1E+12
'


'
    Dim sFind As String, sAddr As String
    Dim rRng As Range, rCl As Range, rFnd As Range
     
    sFind = "ps"   '<-could use InputBox
    Set rRng = Range("Y1:Y27000")
    With rRng
        Set rCl = .Find(sFind, LookIn:=xlValues)
        If Not rCl Is Nothing Then
            sAddr = rCl.Address
            Do
                If rFnd Is Nothing Then
                    Set rFnd = rCl
                Else: Set rFnd = Union(rCl, rFnd)
                End If
                Set rCl = .FindNext(rCl)
            Loop While Not rCl Is Nothing And rCl.Address <> sAddr
        Else: MsgBox "Cannot find " & sFind
            GoTo exit_proc
        End If
    End With


'    Debugger throws a type mismatch error on below line
    
     rFnd.Offset(, 4) = rFnd.Offset(, 4).Value * 1000000000000
    
exit_proc:


End Sub

What am I missing here??

Thanks,
P11
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
You'll receive that error if the Col_AC value on the same row as the Col_Y cell that contains "ps" contains text, instead of a number.
Example:
Y1: ps
AC1: AAAAA
 
Upvote 0
You'll receive that error if the Col_AC value on the same row as the Col_Y cell that contains "ps" contains text, instead of a number.
Example:
Y1: ps
AC1: AAAAA

Thank you. Looks like Y1 was the problem. I set it to Y2:Y27000 and now it is working fine.

Code:
Set rRng = Range("Y1:Y27000")

-P11
 
Upvote 0

Forum statistics

Threads
1,214,646
Messages
6,120,717
Members
448,985
Latest member
chocbudda

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