ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Help with Left() function in VB (https://www.excelbanter.com/excel-programming/368962-help-left-function-vbulletin.html)

erikhs[_17_]

Help with Left() function in VB
 

Hi,

I want to populate an array with the first 4 digits of an 8 digi
code.
But what is the VB syntax for Left(), not Left as a worksheet formula.
This is my example:

For i = 1 to usedrow
Code(i)=Range("a1").offset(i,0).Left( ?, 4) ' What can i writ
here
Next i

Any suggestions will be greatly appreciated

--
erikh
-----------------------------------------------------------------------
erikhs's Profile: http://www.excelforum.com/member.php...fo&userid=3278
View this thread: http://www.excelforum.com/showthread.php?threadid=56698


Andrew Taylor

Help with Left() function in VB
 
Left is a function in VBA, not a method. The format is the
same as for the worksheet function:

Code(i) = Left(Range("a1").Offset(i, 0), 4)



erikhs wrote:
Hi,

I want to populate an array with the first 4 digits of an 8 digit
code.
But what is the VB syntax for Left(), not Left as a worksheet formula.
This is my example:

For i = 1 to usedrow
Code(i)=Range("a1").offset(i,0).Left( ?, 4) ' What can i write
here
Next i

Any suggestions will be greatly appreciated.


--
erikhs
------------------------------------------------------------------------
erikhs's Profile: http://www.excelforum.com/member.php...o&userid=32788
View this thread: http://www.excelforum.com/showthread...hreadid=566985



Niek Otten

Help with Left() function in VB
 
Code(1) = left$(range("a1").Offset(i,0),4)

--
Kind regards,

Niek Otten
Microsoft MVP - Excel

"erikhs" wrote in message
...
|
| Hi,
|
| I want to populate an array with the first 4 digits of an 8 digit
| code.
| But what is the VB syntax for Left(), not Left as a worksheet formula.
| This is my example:
|
| For i = 1 to usedrow
| Code(i)=Range("a1").offset(i,0).Left( ?, 4) ' What can i write
| here
| Next i
|
| Any suggestions will be greatly appreciated.
|
|
| --
| erikhs
| ------------------------------------------------------------------------
| erikhs's Profile: http://www.excelforum.com/member.php...o&userid=32788
| View this thread: http://www.excelforum.com/showthread...hreadid=566985
|



erikhs[_18_]

Help with Left() function in VB
 

Works great! Thank you very much

--
erikh
-----------------------------------------------------------------------
erikhs's Profile: http://www.excelforum.com/member.php...fo&userid=3278
View this thread: http://www.excelforum.com/showthread.php?threadid=56698



All times are GMT +1. The time now is 01:47 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com