![]() |
Left Function in VB
How to i code in VB the Left Function. The user will enter a six character
string in the first column and i need the second column to populate with the first three characters of the first column. Example Column 1 Column 2 ABC100 ABC If i coded it in the worksheet cell B1 , it would be =Left(A1,3), but i want to put in VB as a Worksheet change. Is this possible? Thanks Nathaniel W. Polky =Left(a |
Left Function in VB
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range) Const WS_RANGE As String = "A1:H10" On Error GoTo ws_exit: Application.EnableEvents = False If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then With Target .Offset(0, 1).Value = Left(.Value, 3) End With End If ws_exit: Application.EnableEvents = True End Sub 'This is worksheet event code, which means that it needs to be 'placed in the appropriate worksheet code module, not a standard 'code module. To do this, right-click on the sheet tab, select 'the View Code option from the menu, and paste the code in. -- HTH RP (remove nothere from the email address if mailing direct) "Nathaniel W. Polky" wrote in message ... How to i code in VB the Left Function. The user will enter a six character string in the first column and i need the second column to populate with the first three characters of the first column. Example Column 1 Column 2 ABC100 ABC If i coded it in the worksheet cell B1 , it would be =Left(A1,3), but i want to put in VB as a Worksheet change. Is this possible? Thanks Nathaniel W. Polky =Left(a |
All times are GMT +1. The time now is 04:52 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com