ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   limiting characters in a cell by formula (https://www.excelbanter.com/excel-discussion-misc-queries/101446-limiting-characters-cell-formula.html)

Campbell

limiting characters in a cell by formula
 
Hi,

I am trying to import some information into another software system from
excel, unfortunatley in one particular field there is a limit to the amount
of characters that can be entered, so when I try to import the file it's
rejected.

Is there a way I can limit the amount of characters in excel, for example
the original cell might say "this can't be right" but I need a formula to
limit the amount of characters to say 10 to bring it down to "this can't".

does anyone know of a way to do this, I have a feeling there is a way via
macros or VBA but I am not to flash at these.

Cheers

Campbell

[email protected]

limiting characters in a cell by formula
 

Campbell wrote:
Hi,
Is there a way I can limit the amount of characters in excel, for example
the original cell might say "this can't be right" but I need a formula to
limit the amount of characters to say 10 to bring it down to "this can't".


Cheers

Campbell


Hi Campbell

The formula you want is:

=LEFT(A1,10)

The vba you might want is:

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column < 1 Then Exit Sub
Target = Left(Target, 10)
End Sub

The macro checks the column to limit, in this case column A; amend it
as necessary.

Regards

Steve



All times are GMT +1. The time now is 02:30 AM.

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