ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Comment help (https://www.excelbanter.com/excel-programming/373190-comment-help.html)

ewagz

Comment help
 
I am taking the data from a userform to a comment on the cell the is
currently active. I am running into some errors using the following code
close to the end where the data is concantenated. What I need to do is a
carriage return....I thought that might be CHAR(10) within the comments area
so the outcome in the comments area might look something like this:

Customer name:
DOA:
CC#:
EXP Date:
Days Staying:

Current code:

Private Sub Submit_Click()

Dim res As VbMsgBoxResult

If Custname.Text = "" Then
MsgBox "Please enter a valid name!", vbOKOnly
End If

If CCNo.Text = "" Then
res = MsgBox(Prompt:="Do you want to enter a CC for the customer?", _
Buttons:=vbYesNo + vbQuestion)

If res = vbYes Then user.Custinfo.Show
End If


custnm = Custname.Text
dtoa = DOA.Value
CCN = CCNo.Value
ds = DOS.Value
EX = Exp.Value

com = "Customer name: " & custnm & CHAR(10) & "DOA: " & dtoa & CHAR(10) &
"CC#: " & CCN & _
"EXP Date: " & EX & CHAR(10) & "Days Staying: " & ds

End Sub

Thanks in advance!
--
EW - Analyst

Gary Keramidas

Comment help
 
use chr instead of char

--


Gary


"ewagz" wrote in message
...
I am taking the data from a userform to a comment on the cell the is
currently active. I am running into some errors using the following code
close to the end where the data is concantenated. What I need to do is a
carriage return....I thought that might be CHAR(10) within the comments area
so the outcome in the comments area might look something like this:

Customer name:
DOA:
CC#:
EXP Date:
Days Staying:

Current code:

Private Sub Submit_Click()

Dim res As VbMsgBoxResult

If Custname.Text = "" Then
MsgBox "Please enter a valid name!", vbOKOnly
End If

If CCNo.Text = "" Then
res = MsgBox(Prompt:="Do you want to enter a CC for the customer?", _
Buttons:=vbYesNo + vbQuestion)

If res = vbYes Then user.Custinfo.Show
End If


custnm = Custname.Text
dtoa = DOA.Value
CCN = CCNo.Value
ds = DOS.Value
EX = Exp.Value

com = "Customer name: " & custnm & CHAR(10) & "DOA: " & dtoa & CHAR(10) &
"CC#: " & CCN & _
"EXP Date: " & EX & CHAR(10) & "Days Staying: " & ds

End Sub

Thanks in advance!
--
EW - Analyst




ewagz

Comment help
 
Thanks!
--
EW - Analyst


"Gary Keramidas" wrote:

use chr instead of char

--


Gary


"ewagz" wrote in message
...
I am taking the data from a userform to a comment on the cell the is
currently active. I am running into some errors using the following code
close to the end where the data is concantenated. What I need to do is a
carriage return....I thought that might be CHAR(10) within the comments area
so the outcome in the comments area might look something like this:

Customer name:
DOA:
CC#:
EXP Date:
Days Staying:

Current code:

Private Sub Submit_Click()

Dim res As VbMsgBoxResult

If Custname.Text = "" Then
MsgBox "Please enter a valid name!", vbOKOnly
End If

If CCNo.Text = "" Then
res = MsgBox(Prompt:="Do you want to enter a CC for the customer?", _
Buttons:=vbYesNo + vbQuestion)

If res = vbYes Then user.Custinfo.Show
End If


custnm = Custname.Text
dtoa = DOA.Value
CCN = CCNo.Value
ds = DOS.Value
EX = Exp.Value

com = "Customer name: " & custnm & CHAR(10) & "DOA: " & dtoa & CHAR(10) &
"CC#: " & CCN & _
"EXP Date: " & EX & CHAR(10) & "Days Staying: " & ds

End Sub

Thanks in advance!
--
EW - Analyst





Nigel

Comment help
 
There are vba constants that you could use. easier to remember that chr
numbers!...

vbCr
vbCrLf

--
Cheers
Nigel



"ewagz" wrote in message
...
I am taking the data from a userform to a comment on the cell the is
currently active. I am running into some errors using the following code
close to the end where the data is concantenated. What I need to do is a
carriage return....I thought that might be CHAR(10) within the comments
area
so the outcome in the comments area might look something like this:

Customer name:
DOA:
CC#:
EXP Date:
Days Staying:

Current code:

Private Sub Submit_Click()

Dim res As VbMsgBoxResult

If Custname.Text = "" Then
MsgBox "Please enter a valid name!", vbOKOnly
End If

If CCNo.Text = "" Then
res = MsgBox(Prompt:="Do you want to enter a CC for the customer?", _
Buttons:=vbYesNo + vbQuestion)

If res = vbYes Then user.Custinfo.Show
End If


custnm = Custname.Text
dtoa = DOA.Value
CCN = CCNo.Value
ds = DOS.Value
EX = Exp.Value

com = "Customer name: " & custnm & CHAR(10) & "DOA: " & dtoa & CHAR(10) &
"CC#: " & CCN & _
"EXP Date: " & EX & CHAR(10) & "Days Staying: " & ds

End Sub

Thanks in advance!
--
EW - Analyst





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

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