ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Right Justifying Numbers (https://www.excelbanter.com/excel-programming/299040-right-justifying-numbers.html)

matt

Right Justifying Numbers
 
Hi Everyone

I'm using a spreadsheet as an interface for running
queries. On of the fields is 10 characters in width.
My users will not see it that way however and will just
key in the number of characters that appear on their
reports. To save them putting spaces on the front I have
used below on a Worksheet_Change macro. It works great
for letters but numbers can be entered without the spaces
appearing on the left.

Thanks in advance

Matt

Sub trythis()
Dim strPONoFrom As String * 10
Dim strPONoTo As String * 10

Application.EnableEvents = False
RSet strPONoFrom = Range("A1").Text
Range("A1").Value = strPONoFrom
Application.EnableEvents = True
End Sub


Rob van Gelder[_4_]

Right Justifying Numbers
 
How about using IsNumeric?

eg.
If Not IsNumeric(Range("A1").Text) Then
....
End If


--
Rob van Gelder - http://www.vangelder.co.nz/excel


"Matt" wrote in message
...
Hi Everyone

I'm using a spreadsheet as an interface for running
queries. On of the fields is 10 characters in width.
My users will not see it that way however and will just
key in the number of characters that appear on their
reports. To save them putting spaces on the front I have
used below on a Worksheet_Change macro. It works great
for letters but numbers can be entered without the spaces
appearing on the left.

Thanks in advance

Matt

Sub trythis()
Dim strPONoFrom As String * 10
Dim strPONoTo As String * 10

Application.EnableEvents = False
RSet strPONoFrom = Range("A1").Text
Range("A1").Value = strPONoFrom
Application.EnableEvents = True
End Sub




matt

Right Justifying Numbers
 
Of course!!

Thanks Rob

Matt



-----Original Message-----
How about using IsNumeric?

eg.
If Not IsNumeric(Range("A1").Text) Then
....
End If


--
Rob van Gelder - http://www.vangelder.co.nz/excel


"Matt" wrote in

message
...
Hi Everyone

I'm using a spreadsheet as an interface for running
queries. On of the fields is 10 characters in width.
My users will not see it that way however and will just
key in the number of characters that appear on their
reports. To save them putting spaces on the front I

have
used below on a Worksheet_Change macro. It works great
for letters but numbers can be entered without the

spaces
appearing on the left.

Thanks in advance

Matt

Sub trythis()
Dim strPONoFrom As String * 10
Dim strPONoTo As String * 10

Application.EnableEvents = False
RSet strPONoFrom = Range("A1").Text
Range("A1").Value = strPONoFrom
Application.EnableEvents = True
End Sub



.



All times are GMT +1. The time now is 07:30 PM.

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