Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default 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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default 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



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to nest a left function within a sumif function? LisaK Excel Worksheet Functions 2 April 23rd 23 11:46 AM
LEFT function-all to left of a comma? Jennifer F Excel Worksheet Functions 1 January 21st 09 11:19 PM
Left vs Left$ function Andy Excel Discussion (Misc queries) 5 May 6th 07 04:06 AM
Left function Allan Excel Discussion (Misc queries) 4 December 3rd 05 03:13 PM
HOW DO I NEST THE VLOOKUP FUNCTION WITH THE LEFT FUNCTION CHAIM Excel Worksheet Functions 1 July 27th 05 09:10 PM


All times are GMT +1. The time now is 10:10 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"