vba help - Left formula not working, error type mismatch

Mallesh23

Well-known Member
Joined
Feb 4, 2009
Messages
976
Office Version
  1. 2010
Platform
  1. Windows
Hi Team,

Getting Type mismatch , unable to apply left function.
Whats wrong in my code.

VBA Code:
Sub Test()
  
  Dim sht As Worksheet
  Set sht = ThisWorkbook.Worksheets("Sheet1")
  
  Dim lr As Long
  lr = sht.Range("a1").CurrentRegion.Rows.Count
  
  With sht
        With .Range(.Cells(2, 2), .Cells(lr, 2)).FormulaR1C1 = "=LEFT(RC1,3)" 'Error Type Mismatch.
            .Value = .Value
        End With
    End With
End Sub

Account NOFirst 3 Digit character
26808​
268
35147​
351
36264​
362
33102​
331
36766​
367
25526​
255
25944​
259
25888​
258
36852​
368
35466​
354


Thanks
mg
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
You need to move the .FormulaR1C1 part to a new line
 
Upvote 0
That should be split into 2 lines:

Code:
With .Range(.Cells(2, 2), .Cells(lr, 2))
    .FormulaR1C1 = "=LEFT(RC1,3)" 'Error Type Mismatch.
    .Value = .Value
End With
 
Upvote 0
What are you trying to do? Add =LEFT in Column B for the cells in Column A?
 
Upvote 0
Hi Fluff /Rory

Thanks for your help, understood. (y)

Thanks
mg
 
Upvote 0
Glad we could help & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,932
Messages
6,122,332
Members
449,077
Latest member
jmsotelo

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