Right Justifying Numbers

  • Thread starter Thread starter Matt
  • Start date Start date
M

Matt

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
 
How about using IsNumeric?

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top