Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Sue Sue is offline
external usenet poster
 
Posts: 285
Default Invoice Number Problem

Hi

I have a textbox on a Userform and using the code below
when I enter for example 100 and then in the Listbox select another row the
textbox updates to 101 with no problem - however if I enter L100 the code
errors
is there a way round this error as sometimes I have to use a letter as it
denotes the department that is issuing the Invoice.

Private Sub Lb1_Change()
Application.ScreenUpdating = False
Dim invnum As String
Dim iRow As Long
Dim ws As Worksheet
Sheets("Invoice").Select
Tb36A.Text = Range("C14").Text + 1'<<<< errors on this line
Application.ScreenUpdating = True
End Sub

--
Many Thanks

Sue
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Invoice Number Problem

Sue,

Prefixing a number with a letter turns it into text so adding 1 to a text
string causes an error. Do it like this by just having the number in C14 and
add the L at runtime

Tb36A.Text = "L" & Range("C14").Text + 1

Mike

"Sue" wrote:

Hi

I have a textbox on a Userform and using the code below
when I enter for example 100 and then in the Listbox select another row the
textbox updates to 101 with no problem - however if I enter L100 the code
errors
is there a way round this error as sometimes I have to use a letter as it
denotes the department that is issuing the Invoice.

Private Sub Lb1_Change()
Application.ScreenUpdating = False
Dim invnum As String
Dim iRow As Long
Dim ws As Worksheet
Sheets("Invoice").Select
Tb36A.Text = Range("C14").Text + 1'<<<< errors on this line
Application.ScreenUpdating = True
End Sub

--
Many Thanks

Sue

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Invoice Number Problem

I just noticed that you say you 'sometimes add a letter. Same principle but
add the letter from another range address. It wouldn't matter if that address
was empty

Tb36A.Text = Range("Z1").Text & Range("C14").Text + 1

Mike

"Mike H" wrote:

Sue,

Prefixing a number with a letter turns it into text so adding 1 to a text
string causes an error. Do it like this by just having the number in C14 and
add the L at runtime

Tb36A.Text = "L" & Range("C14").Text + 1

Mike

"Sue" wrote:

Hi

I have a textbox on a Userform and using the code below
when I enter for example 100 and then in the Listbox select another row the
textbox updates to 101 with no problem - however if I enter L100 the code
errors
is there a way round this error as sometimes I have to use a letter as it
denotes the department that is issuing the Invoice.

Private Sub Lb1_Change()
Application.ScreenUpdating = False
Dim invnum As String
Dim iRow As Long
Dim ws As Worksheet
Sheets("Invoice").Select
Tb36A.Text = Range("C14").Text + 1'<<<< errors on this line
Application.ScreenUpdating = True
End Sub

--
Many Thanks

Sue

  #4   Report Post  
Posted to microsoft.public.excel.programming
Sue Sue is offline
external usenet poster
 
Posts: 285
Default Invoice Number Problem

Hi Mike

Thanks for quick reply however I forgot to mention I may have 4 or 5
invoices following one another with a single letter prefix for the same
department -- after entering letter L in ("Z1") first time works OK when
changing to next line in the ListBox ready to enter next invoice it gives a
runtime error'13' - Type Mismatch -- can you help.
--
Many Thanks

Sue


"Mike H" wrote:

I just noticed that you say you 'sometimes add a letter. Same principle but
add the letter from another range address. It wouldn't matter if that address
was empty

Tb36A.Text = Range("Z1").Text & Range("C14").Text + 1

Mike

"Mike H" wrote:

Sue,

Prefixing a number with a letter turns it into text so adding 1 to a text
string causes an error. Do it like this by just having the number in C14 and
add the L at runtime

Tb36A.Text = "L" & Range("C14").Text + 1

Mike

"Sue" wrote:

Hi

I have a textbox on a Userform and using the code below
when I enter for example 100 and then in the Listbox select another row the
textbox updates to 101 with no problem - however if I enter L100 the code
errors
is there a way round this error as sometimes I have to use a letter as it
denotes the department that is issuing the Invoice.

Private Sub Lb1_Change()
Application.ScreenUpdating = False
Dim invnum As String
Dim iRow As Long
Dim ws As Worksheet
Sheets("Invoice").Select
Tb36A.Text = Range("C14").Text + 1'<<<< errors on this line
Application.ScreenUpdating = True
End Sub

--
Many Thanks

Sue

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Invoice Number Problem

**IF** your values in C14 are **always** two digits long or more, and if
your letter prefix is **always** a single character, you can use this line
in place of the one that caused the error originally...

Tb36A.Text = Left(range("C14", 1) & (Mid(range("C14", 2) + 1)

--
Rick (MVP - Excel)


"Sue" wrote in message
...
Hi Mike

Thanks for quick reply however I forgot to mention I may have 4 or 5
invoices following one another with a single letter prefix for the same
department -- after entering letter L in ("Z1") first time works OK when
changing to next line in the ListBox ready to enter next invoice it gives
a
runtime error'13' - Type Mismatch -- can you help.
--
Many Thanks

Sue


"Mike H" wrote:

I just noticed that you say you 'sometimes add a letter. Same principle
but
add the letter from another range address. It wouldn't matter if that
address
was empty

Tb36A.Text = Range("Z1").Text & Range("C14").Text + 1

Mike

"Mike H" wrote:

Sue,

Prefixing a number with a letter turns it into text so adding 1 to a
text
string causes an error. Do it like this by just having the number in
C14 and
add the L at runtime

Tb36A.Text = "L" & Range("C14").Text + 1

Mike

"Sue" wrote:

Hi

I have a textbox on a Userform and using the code below
when I enter for example 100 and then in the Listbox select another
row the
textbox updates to 101 with no problem - however if I enter L100 the
code
errors
is there a way round this error as sometimes I have to use a letter
as it
denotes the department that is issuing the Invoice.

Private Sub Lb1_Change()
Application.ScreenUpdating = False
Dim invnum As String
Dim iRow As Long
Dim ws As Worksheet
Sheets("Invoice").Select
Tb36A.Text = Range("C14").Text + 1'<<<< errors on this line
Application.ScreenUpdating = True
End Sub

--
Many Thanks

Sue




  #6   Report Post  
Posted to microsoft.public.excel.programming
Sue Sue is offline
external usenet poster
 
Posts: 285
Default Invoice Number Problem

Hi Rick

Thanks for your reply

Working late tonight most of the UK snowed up probably stay at a local hotel
so I can get to work tomorrow.

everything meets the If conditions that you asked about and I'm receiving an
error message highlighted in debug at Mid - compile error -- argument not
optional.

Tb36A.Text = Left(range("C14", 1) & (Mid(range("C14", 2) + 1)




--
Many Thanks

Sue


"Rick Rothstein" wrote:

**IF** your values in C14 are **always** two digits long or more, and if
your letter prefix is **always** a single character, you can use this line
in place of the one that caused the error originally...

Tb36A.Text = Left(range("C14", 1) & (Mid(range("C14", 2) + 1)

--
Rick (MVP - Excel)


"Sue" wrote in message
...
Hi Mike

Thanks for quick reply however I forgot to mention I may have 4 or 5
invoices following one another with a single letter prefix for the same
department -- after entering letter L in ("Z1") first time works OK when
changing to next line in the ListBox ready to enter next invoice it gives
a
runtime error'13' - Type Mismatch -- can you help.
--
Many Thanks

Sue


"Mike H" wrote:

I just noticed that you say you 'sometimes add a letter. Same principle
but
add the letter from another range address. It wouldn't matter if that
address
was empty

Tb36A.Text = Range("Z1").Text & Range("C14").Text + 1

Mike

"Mike H" wrote:

Sue,

Prefixing a number with a letter turns it into text so adding 1 to a
text
string causes an error. Do it like this by just having the number in
C14 and
add the L at runtime

Tb36A.Text = "L" & Range("C14").Text + 1

Mike

"Sue" wrote:

Hi

I have a textbox on a Userform and using the code below
when I enter for example 100 and then in the Listbox select another
row the
textbox updates to 101 with no problem - however if I enter L100 the
code
errors
is there a way round this error as sometimes I have to use a letter
as it
denotes the department that is issuing the Invoice.

Private Sub Lb1_Change()
Application.ScreenUpdating = False
Dim invnum As String
Dim iRow As Long
Dim ws As Worksheet
Sheets("Invoice").Select
Tb36A.Text = Range("C14").Text + 1'<<<< errors on this line
Application.ScreenUpdating = True
End Sub

--
Many Thanks

Sue



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
invoice toolbar for invoice calcuation and assign number KarenY Excel Discussion (Misc queries) 15 March 16th 07 12:02 PM
How do I assign an invoice number using the invoice toolbar? Sharon Excel Worksheet Functions 1 December 23rd 06 09:32 AM
how do I set up an escalating number (EG) invoice number tg Excel Discussion (Misc queries) 1 September 2nd 06 06:44 AM
How do I generate a new invoice number when creating new invoice? KiddieWonderland Excel Discussion (Misc queries) 1 March 15th 06 03:19 AM
How do I change the invoice number assigned in Invoice template... akress Excel Discussion (Misc queries) 1 February 28th 05 06:36 PM


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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"