Using Left in VBA

michaeltsmith93

Board Regular
Joined
Sep 29, 2016
Messages
83
Hi,

I'd like to change the following code such that only the Left three characters of the Department value are taken. Left tutorials aren't helping me much.

Code:
With ws


    .Cells(ERow, 1).Value = Me.ptmember.Value
    .Cells(ERow, 2).Value = Me.StudyRole.Value
    .Cells(ERow, 4).Value = Me.MatrixRole.Value
    .Cells(ERow, 5).Value = [COLOR=#ff0000]Me.Department.Value[/COLOR]
    
End With
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
What issues are you having, it should be the same syntax as the worksheet function...

Code:
.Cells(ERow, 5).Value = Left(Me.Department.Value, 3)
 
Upvote 0
Mark858, that makes perfect sense. Another tutorial had the Value function outside and Left afterward, and that confused me. Thank you both.
 
Upvote 0
Try this.
Code:
    .Cells(ERow, 5).Value = Left(Me.Department.Value, 3)
 
Upvote 0

Forum statistics

Threads
1,223,228
Messages
6,170,871
Members
452,363
Latest member
merico17

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