userform label set enter

  • Thread starter Thread starter Alberto Ast
  • Start date Start date
A

Alberto Ast

I have a userform label set to a specific value copied from two cells.. can I
have an enter betwen both cells value?

Me.Label5 = Range("e12").Value & Range("e13").Value

I would like it to show

ECR
123456

where
ECR is the value in cell c12
123456 is the value in cell e13

it actualy shows
ECR123456
 
Try

Me.Label5 = Range("e12").Value & vbCrLf & Range("e13").Value

Cordially,
Chip Pearson
Microsoft MVP 1998 - 2010
Pearson Software Consulting, LLC
www.cpearson.com
[email on web site]
 
Try concatenating vbLf between them...

Me.Label5 = Range("e12").Value & vbLf & Range("e13").Value
 
One more way for interest, if the cells are contiguous -

Dim dObj As DataObject
Set dObj = New DataObject
Range("A1:C3").Copy

dObj.GetFromClipboard
Me.Label1 = dObj.GetText(1)
Application.CutCopyMode = False

If only a few cells or non-contiguous stick with what you've got.

Regards,
Peter T
 
Thanks it works great but I have one question...
What is the difference among

vbCr, vbCrLf and vbLf?
 
I'm not completely sure of your question; see if this answers it. These are
predefined constants in VB... vbCr is a Carriage Return character (ASCII
13), vbLf is a Line Feed character (ASCII 10) and vbCrLf is two
characters... a Carriage Return followed by a Line Feed. You can think of
this last one like this...

vbCrLf <==> vbCr & vbLf

Generally, for text files, the vbLf character is used as the "newline"
character in UNIX and Linux operating systems; the vbCr character is used as
the "newline" character in Mac computers and the vbCrLf combination of
characters is used as the "newline" character sequence in Windows systems.
For whatever reason, Microsoft decided to use vbLf for "newlines" in Excel
cell text, MessageBoxes, Labels, etc., contrary to their own established
vbCrLf convention used in Windows text files.
 
Back
Top