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

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes

Ron Coderre

MrExcel MVP
Joined
Jan 14, 2009
Messages
2,316
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
 

paul11

New Member
Joined
Dec 30, 2012
Messages
2
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
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,152,821
Messages
5,772,464
Members
425,760
Latest member
paphon

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
Top