PC Review


Reply
Thread Tools Rate Thread

Accounting Format Text in a Textbox

 
 
RyanH
Guest
Posts: n/a
 
      9th Sep 2008
I have a Textbox on a Userform that I want its text to be in an Accounting
Format when data is entered into it. This is an example of what I am trying
to do.

Private Sub Textbox1_AfterUpdate()
Textbox1.Value = Format(Textbox1, Accounting)
End Sub

I also retrieve cell values (that are formated as Accounting) into Textbox1
with my Worksheet Double Click Event. But it does not display the dollar
sign, why and how can I do this?

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
Boolean)

'autofills the user form with the data from global schedule worksheet
Cancel = True

With frmItemSummary
.Textbox1 = Cells(Target.Row, "A")
End With

End Sub
--
Cheers,
Ryan
 
Reply With Quote
 
 
 
 
Dave Peterson
Guest
Posts: n/a
 
      10th Sep 2008
Maybe...

Private Sub Textbox1_AfterUpdate()
Dim AccountingFormat As String
AccountingFormat = "$* #,##0.00;$* (#,##0.00)"

Me.TextBox1.Value = Format(Me.TextBox1.Value, AccountingFormat)
End Sub


RyanH wrote:
>
> I have a Textbox on a Userform that I want its text to be in an Accounting
> Format when data is entered into it. This is an example of what I am trying
> to do.
>
> Private Sub Textbox1_AfterUpdate()
> Textbox1.Value = Format(Textbox1, Accounting)
> End Sub
>
> I also retrieve cell values (that are formated as Accounting) into Textbox1
> with my Worksheet Double Click Event. But it does not display the dollar
> sign, why and how can I do this?
>
> Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
> Boolean)
>
> 'autofills the user form with the data from global schedule worksheet
> Cancel = True
>
> With frmItemSummary
> .Textbox1 = Cells(Target.Row, "A")
> End With
>
> End Sub
> --
> Cheers,
> Ryan


--

Dave Peterson
 
Reply With Quote
 
RyanH
Guest
Posts: n/a
 
      10th Sep 2008
When I load the cell value into Textbox1 when the userform is called it looks
just like a accounting format, plus if I don't change the text, when I click
my "Apply" button in applies the value to the cell just fine.

The problem happens when I change the Textbox1 value. I can only add a $
right next to the first number instead of it looking like it has a
"Accounting" format.

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
Boolean)

frmItemSummary.Textbox1 = Cells(Target.Row, "A")
frmItemSummary.Show

End Sub

Private Sub btnApply_Click()
Sheets("Global Schedule").Cells(ActiveCell.Row, "A") = Textbox1
End Sub
--
Cheers,
Ryan


"Dave Peterson" wrote:

> Maybe...
>
> Private Sub Textbox1_AfterUpdate()
> Dim AccountingFormat As String
> AccountingFormat = "$* #,##0.00;$* (#,##0.00)"
>
> Me.TextBox1.Value = Format(Me.TextBox1.Value, AccountingFormat)
> End Sub
>
>
> RyanH wrote:
> >
> > I have a Textbox on a Userform that I want its text to be in an Accounting
> > Format when data is entered into it. This is an example of what I am trying
> > to do.
> >
> > Private Sub Textbox1_AfterUpdate()
> > Textbox1.Value = Format(Textbox1, Accounting)
> > End Sub
> >
> > I also retrieve cell values (that are formated as Accounting) into Textbox1
> > with my Worksheet Double Click Event. But it does not display the dollar
> > sign, why and how can I do this?
> >
> > Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
> > Boolean)
> >
> > 'autofills the user form with the data from global schedule worksheet
> > Cancel = True
> >
> > With frmItemSummary
> > .Textbox1 = Cells(Target.Row, "A")
> > End With
> >
> > End Sub
> > --
> > Cheers,
> > Ryan

>
> --
>
> Dave Peterson
>

 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      10th Sep 2008
You could just add as many space characters as you want:

Private Sub Textbox1_AfterUpdate()
Dim AccountingFormat As String
Dim HowManyCharacters As Long
Dim myStr As String

HowManyChars = 12
AccountingFormat = "#,##0.00;(#,##0.00)"

myStr = "$" & Right(Space(HowManyChars) _
& Format(Me.TextBox1.Value, AccountingFormat), HowManyChars)

Me.TextBox1.Value = myStr
End Sub



RyanH wrote:
>
> When I load the cell value into Textbox1 when the userform is called it looks
> just like a accounting format, plus if I don't change the text, when I click
> my "Apply" button in applies the value to the cell just fine.
>
> The problem happens when I change the Textbox1 value. I can only add a $
> right next to the first number instead of it looking like it has a
> "Accounting" format.
>
> Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
> Boolean)
>
> frmItemSummary.Textbox1 = Cells(Target.Row, "A")
> frmItemSummary.Show
>
> End Sub
>
> Private Sub btnApply_Click()
> Sheets("Global Schedule").Cells(ActiveCell.Row, "A") = Textbox1
> End Sub
> --
> Cheers,
> Ryan
>
> "Dave Peterson" wrote:
>
> > Maybe...
> >
> > Private Sub Textbox1_AfterUpdate()
> > Dim AccountingFormat As String
> > AccountingFormat = "$* #,##0.00;$* (#,##0.00)"
> >
> > Me.TextBox1.Value = Format(Me.TextBox1.Value, AccountingFormat)
> > End Sub
> >
> >
> > RyanH wrote:
> > >
> > > I have a Textbox on a Userform that I want its text to be in an Accounting
> > > Format when data is entered into it. This is an example of what I am trying
> > > to do.
> > >
> > > Private Sub Textbox1_AfterUpdate()
> > > Textbox1.Value = Format(Textbox1, Accounting)
> > > End Sub
> > >
> > > I also retrieve cell values (that are formated as Accounting) into Textbox1
> > > with my Worksheet Double Click Event. But it does not display the dollar
> > > sign, why and how can I do this?
> > >
> > > Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
> > > Boolean)
> > >
> > > 'autofills the user form with the data from global schedule worksheet
> > > Cancel = True
> > >
> > > With frmItemSummary
> > > .Textbox1 = Cells(Target.Row, "A")
> > > End With
> > >
> > > End Sub
> > > --
> > > Cheers,
> > > Ryan

> >
> > --
> >
> > Dave Peterson
> >


--

Dave Peterson
 
Reply With Quote
 
RyanH
Guest
Posts: n/a
 
      10th Sep 2008
I guess that will have to do. Thanks for the help!
--
Cheers,
Ryan


"Dave Peterson" wrote:

> You could just add as many space characters as you want:
>
> Private Sub Textbox1_AfterUpdate()
> Dim AccountingFormat As String
> Dim HowManyCharacters As Long
> Dim myStr As String
>
> HowManyChars = 12
> AccountingFormat = "#,##0.00;(#,##0.00)"
>
> myStr = "$" & Right(Space(HowManyChars) _
> & Format(Me.TextBox1.Value, AccountingFormat), HowManyChars)
>
> Me.TextBox1.Value = myStr
> End Sub
>
>
>
> RyanH wrote:
> >
> > When I load the cell value into Textbox1 when the userform is called it looks
> > just like a accounting format, plus if I don't change the text, when I click
> > my "Apply" button in applies the value to the cell just fine.
> >
> > The problem happens when I change the Textbox1 value. I can only add a $
> > right next to the first number instead of it looking like it has a
> > "Accounting" format.
> >
> > Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
> > Boolean)
> >
> > frmItemSummary.Textbox1 = Cells(Target.Row, "A")
> > frmItemSummary.Show
> >
> > End Sub
> >
> > Private Sub btnApply_Click()
> > Sheets("Global Schedule").Cells(ActiveCell.Row, "A") = Textbox1
> > End Sub
> > --
> > Cheers,
> > Ryan
> >
> > "Dave Peterson" wrote:
> >
> > > Maybe...
> > >
> > > Private Sub Textbox1_AfterUpdate()
> > > Dim AccountingFormat As String
> > > AccountingFormat = "$* #,##0.00;$* (#,##0.00)"
> > >
> > > Me.TextBox1.Value = Format(Me.TextBox1.Value, AccountingFormat)
> > > End Sub
> > >
> > >
> > > RyanH wrote:
> > > >
> > > > I have a Textbox on a Userform that I want its text to be in an Accounting
> > > > Format when data is entered into it. This is an example of what I am trying
> > > > to do.
> > > >
> > > > Private Sub Textbox1_AfterUpdate()
> > > > Textbox1.Value = Format(Textbox1, Accounting)
> > > > End Sub
> > > >
> > > > I also retrieve cell values (that are formated as Accounting) into Textbox1
> > > > with my Worksheet Double Click Event. But it does not display the dollar
> > > > sign, why and how can I do this?
> > > >
> > > > Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
> > > > Boolean)
> > > >
> > > > 'autofills the user form with the data from global schedule worksheet
> > > > Cancel = True
> > > >
> > > > With frmItemSummary
> > > > .Textbox1 = Cells(Target.Row, "A")
> > > > End With
> > > >
> > > > End Sub
> > > > --
> > > > Cheers,
> > > > Ryan
> > >
> > > --
> > >
> > > Dave Peterson
> > >

>
> --
>
> Dave Peterson
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Validate Text in Textbox to Ensure Text is a Valid Price Format Ryan H Microsoft Excel Programming 1 12th Nov 2009 07:35 PM
how to format text in textbox? ghost Microsoft Excel Misc 1 18th May 2008 10:41 AM
Text box - Accounting Format =?Utf-8?B?TWF0dHM=?= Microsoft Excel Programming 0 6th Sep 2007 12:58 PM
textbox text format in web app =?Utf-8?B?RGF2aWQ=?= Microsoft Dot NET 2 6th Jul 2007 03:24 PM
Format text in a textbox =?Utf-8?B?REI=?= Microsoft Excel Programming 3 9th Feb 2006 03:46 PM


Features
 

Advertising
 

Newsgroups
 


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