Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 209
Default Number in forms

Hi!!
I shall make this form, and in this form
i shall use a number like a ID there every
time i start this form i get a new number
like if the last number i use was 0098 then
i get 0099 when i start the form. And when
i save the file the file name shal bee the number
i just get like 0099. hope someone can help how to do this

Best regards

Alvin

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Number in forms

Hi alvin

You can format the cell like this
Ctrl-1
Numbercustom
Type : Enter 0000 there

In a macro you can use this

With Sheets("sheet1").Range("A1")
..Value = .Value + 1
End With



--
Regards Ron de Bruin
http://www.rondebruin.nl


"Alvin Hansen" wrote in message ...
Hi!!
I shall make this form, and in this form
i shall use a number like a ID there every
time i start this form i get a new number
like if the last number i use was 0098 then
i get 0099 when i start the form. And when
i save the file the file name shal bee the number
i just get like 0099. hope someone can help how to do this

Best regards

Alvin



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Number in forms

Hi ALvin,

You could define a name in your workbook, and use this value when the file
opens.

Add this code to theThisWorkbook code module within the workbook and it will
automatically increment the Name UniqueId every time the workbook is opened.

You can then acess that name in your code by plugging this into the existing
code that needs the Id.

Evaluate(ThisWorkbook).Names("_UniqueId").RefersTo )


'-------------------------------------------------------------
Private Sub Workbook_Open()

'-------------------------------------------------------------
GetId
End Sub


'-------------------------------------------------------------
Private Sub GetId()
'-------------------------------------------------------------
Dim myId As Long

myId= 1 ' in case it doesn't already exist
On Error Resume Next
UniqueId = Evaluate(ThisWorkbokNames("_UniqueId").RefersTo) + 1
ThisWorkbook.Names.Add Name:="_UniqueId", RefersTo:="=" & myId

End Sub
'-------------------------------------------------------------


--

HTH

RP
(remove nothere from the email address if mailing direct)


"Alvin Hansen" wrote in message
...
Hi!!
I shall make this form, and in this form
i shall use a number like a ID there every
time i start this form i get a new number
like if the last number i use was 0098 then
i get 0099 when i start the form. And when
i save the file the file name shal bee the number
i just get like 0099. hope someone can help how to do this

Best regards

Alvin



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 209
Default Number in forms

Thanks
I can see how....
But in my Cell i have 0001
and i my form i only get 1
why?

Alvin


"Ron de Bruin" skrev:

Hi alvin

You can format the cell like this
Ctrl-1
Numbercustom
Type : Enter 0000 there

In a macro you can use this

With Sheets("sheet1").Range("A1")
..Value = .Value + 1
End With



--
Regards Ron de Bruin
http://www.rondebruin.nl


"Alvin Hansen" wrote in message ...
Hi!!
I shall make this form, and in this form
i shall use a number like a ID there every
time i start this form i get a new number
like if the last number i use was 0098 then
i get 0099 when i start the form. And when
i save the file the file name shal bee the number
i just get like 0099. hope someone can help how to do this

Best regards

Alvin




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Number in forms

Ahha

You mean a Userform
You can use the Format function to do this

Private Sub UserForm_Initialize()
Me.TextBox1.Text = Format(Sheets("Sheet1").Range("A1").Value, "0000")
End Sub



--
Regards Ron de Bruin
http://www.rondebruin.nl


"Alvin Hansen" wrote in message ...
Thanks
I can see how....
But in my Cell i have 0001
and i my form i only get 1
why?

Alvin


"Ron de Bruin" skrev:

Hi alvin

You can format the cell like this
Ctrl-1
Numbercustom
Type : Enter 0000 there

In a macro you can use this

With Sheets("sheet1").Range("A1")
..Value = .Value + 1
End With



--
Regards Ron de Bruin
http://www.rondebruin.nl


"Alvin Hansen" wrote in message
...
Hi!!
I shall make this form, and in this form
i shall use a number like a ID there every
time i start this form i get a new number
like if the last number i use was 0098 then
i get 0099 when i start the form. And when
i save the file the file name shal bee the number
i just get like 0099. hope someone can help how to do this

Best regards

Alvin








  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 209
Default Number in forms

Thanks
It's working
Thank you

alvin


"Ron de Bruin" skrev:

Ahha

You mean a Userform
You can use the Format function to do this

Private Sub UserForm_Initialize()
Me.TextBox1.Text = Format(Sheets("Sheet1").Range("A1").Value, "0000")
End Sub



--
Regards Ron de Bruin
http://www.rondebruin.nl


"Alvin Hansen" wrote in message ...
Thanks
I can see how....
But in my Cell i have 0001
and i my form i only get 1
why?

Alvin


"Ron de Bruin" skrev:

Hi alvin

You can format the cell like this
Ctrl-1
Numbercustom
Type : Enter 0000 there

In a macro you can use this

With Sheets("sheet1").Range("A1")
..Value = .Value + 1
End With



--
Regards Ron de Bruin
http://www.rondebruin.nl


"Alvin Hansen" wrote in message
...
Hi!!
I shall make this form, and in this form
i shall use a number like a ID there every
time i start this form i get a new number
like if the last number i use was 0098 then
i get 0099 when i start the form. And when
i save the file the file name shal bee the number
i just get like 0099. hope someone can help how to do this

Best regards

Alvin







  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 137
Default Number in forms

Hi Ron,

I was reading what you wrote to Alvin, and I tried your suggestion.
However, I can't make it work for me. Does it make a difference in the
version of excel you are using?

"Ron de Bruin" wrote:

Hi alvin

You can format the cell like this
Ctrl-1
Numbercustom
Type : Enter 0000 there

In a macro you can use this

With Sheets("sheet1").Range("A1")
..Value = .Value + 1
End With



--
Regards Ron de Bruin
http://www.rondebruin.nl


"Alvin Hansen" wrote in message ...
Hi!!
I shall make this form, and in this form
i shall use a number like a ID there every
time i start this form i get a new number
like if the last number i use was 0098 then
i get 0099 when i start the form. And when
i save the file the file name shal bee the number
i just get like 0099. hope someone can help how to do this

Best regards

Alvin




  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Number in forms

Hi Brenda

It is working in 97-2003

I can't make it work for me

What have you done?


--
Regards Ron de Bruin
http://www.rondebruin.nl


"Brenda" wrote in message ...
Hi Ron,

I was reading what you wrote to Alvin, and I tried your suggestion.
However, I can't make it work for me. Does it make a difference in the
version of excel you are using?

"Ron de Bruin" wrote:

Hi alvin

You can format the cell like this
Ctrl-1
Numbercustom
Type : Enter 0000 there

In a macro you can use this

With Sheets("sheet1").Range("A1")
..Value = .Value + 1
End With



--
Regards Ron de Bruin
http://www.rondebruin.nl


"Alvin Hansen" wrote in message
...
Hi!!
I shall make this form, and in this form
i shall use a number like a ID there every
time i start this form i get a new number
like if the last number i use was 0098 then
i get 0099 when i start the form. And when
i save the file the file name shal bee the number
i just get like 0099. hope someone can help how to do this

Best regards

Alvin






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
How do i automaticaly number consecutive forms Stan O. Terry Excel Worksheet Functions 2 February 8th 07 03:02 AM
Need to automatically number order forms in excel upon opening? Mike1 Excel Discussion (Misc queries) 2 May 16th 06 07:59 PM
VBA forms - HELP!!! One-Leg Excel Discussion (Misc queries) 8 December 15th 04 08:15 PM
Forms that open from forms Azza Excel Programming 1 October 12th 04 10:54 PM
Calling Forms from Forms - Exit problems Stuart[_5_] Excel Programming 3 May 25th 04 06:50 AM


All times are GMT +1. The time now is 05:03 AM.

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

About Us

"It's about Microsoft Excel"