using left function in VBA

ExcelHobbit

New Member
Joined
Jan 8, 2020
Messages
23
Office Version
  1. 2010
Platform
  1. Windows
Hello,

I want to use the left function in VBA, though not in a formula. have the following code, but it isn't working - could be for obvious reasons:

VBA Code:
Range("A2").Select
ActiveCell.Offset(1, 0).Activate

Do Until Cells(ActiveCell.Row, "A").Value = ""
    If Left(Cells(ActiveCell.Row, "A"), 1).Value = "L" Then
    Cells(ActiveCell.Row, "G").FormulaR1C1 = "IFERROR(VLOOKUP(RC4, 'Sheet2'!C1:C4,3,False), """")"
    ActiveCell.Value = ActiveCell.Value
    Else
        If Left(Cells(ActiveCell.Row, "A"), 1).Value = "Q" Then
        Cells(ActiveCell.Row, "G").FormulaR1C1 = "IFERROR(VLOOKUP(RC4, 'Sheet3'!C1:C4,3,False), """")"
        ActiveCell.Value = ActiveCell.Value
        Else
        ActiveCell.Offset(1, 0).Activate
        End If
    End If
Loop

any help would be greatly appreciated.


thanks,
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
ActiveCell.Value = ActiveCell.Value is also wrong or no use
 
Upvote 0
You are welcome
And thank you for the feedback
Be happy & safe
 
Upvote 0

Forum statistics

Threads
1,214,593
Messages
6,120,434
Members
448,961
Latest member
nzskater

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