Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Cathy Landry
 
Posts: n/a
Default how to auto assign po numbers in Excel

Larry, Thank you for the input. The code did work, but I do have another
small problem. I used the code as a macro and assigned it to a button.
Ideally, we want users to be able to click the button to generate a
po#......which it does, but we also want the cell locked so they cannot
change the number or create their own. When the macro is run a box pops up
asking for a password as the cell has been locked. Is there a way to put
that into the code so the macro will run and not generate that message?

Thank you
Cathy
  #2   Report Post  
Rowan
 
Posts: n/a
Default

I don't know what the original code looks like but you probably need to
unprotect the sheet and protect it again in your macro something like:

ActiveSheet.Unprotect Password:="thepassword"
'rest of code
ActiveSheet.Protect Password:="thepassword"

Hope this helps
Rowan

"Cathy Landry" wrote:

Larry, Thank you for the input. The code did work, but I do have another
small problem. I used the code as a macro and assigned it to a button.
Ideally, we want users to be able to click the button to generate a
po#......which it does, but we also want the cell locked so they cannot
change the number or create their own. When the macro is run a box pops up
asking for a password as the cell has been locked. Is there a way to put
that into the code so the macro will run and not generate that message?

Thank you
Cathy

  #3   Report Post  
Larry E
 
Posts: n/a
Default

Rowan, this is the code I told her to use:

Private Sub Workbook_Open()
Dim FName As String
Dim FNo As String
Dim x As Long
FName = ThisWorkbook.Path & Application.PathSeparator & "Number.Txt"
FNo = FreeFile
x = 0
On Error Resume Next
Open FName For Input As #FNo
Input #FNo, x
x = x + 1
' *** Change range reference to suit ***
Range("K1").Value = x
Close #FNo
FNo = FreeFile
Open FName For Output As #FNo
Write #1, x
Close #FNo
End Sub


Kathy, you really should have posted this on your original posting so as not
to confuse readers.

Larry

"Rowan" wrote:

I don't know what the original code looks like but you probably need to
unprotect the sheet and protect it again in your macro something like:

ActiveSheet.Unprotect Password:="thepassword"
'rest of code
ActiveSheet.Protect Password:="thepassword"

Hope this helps
Rowan

"Cathy Landry" wrote:

Larry, Thank you for the input. The code did work, but I do have another
small problem. I used the code as a macro and assigned it to a button.
Ideally, we want users to be able to click the button to generate a
po#......which it does, but we also want the cell locked so they cannot
change the number or create their own. When the macro is run a box pops up
asking for a password as the cell has been locked. Is there a way to put
that into the code so the macro will run and not generate that message?

Thank you
Cathy

  #4   Report Post  
Cathy Landry
 
Posts: n/a
Default

Thank you all for your help! Is there a class (online) that teaches the
novice in Visual Basic?

Cathy

"Rowan" wrote:

I don't know what the original code looks like but you probably need to
unprotect the sheet and protect it again in your macro something like:

ActiveSheet.Unprotect Password:="thepassword"
'rest of code
ActiveSheet.Protect Password:="thepassword"

Hope this helps
Rowan

"Cathy Landry" wrote:

Larry, Thank you for the input. The code did work, but I do have another
small problem. I used the code as a macro and assigned it to a button.
Ideally, we want users to be able to click the button to generate a
po#......which it does, but we also want the cell locked so they cannot
change the number or create their own. When the macro is run a box pops up
asking for a password as the cell has been locked. Is there a way to put
that into the code so the macro will run and not generate that message?

Thank you
Cathy

  #5   Report Post  
Larry E
 
Posts: n/a
Default

You might want to check out "Mr. Excel" at www.mrexcel.com it's a great place
to post questions and problems. They also have some books and videos that
you might find useful.

Larry

"Cathy Landry" wrote:

Thank you all for your help! Is there a class (online) that teaches the
novice in Visual Basic?

Cathy

"Rowan" wrote:

I don't know what the original code looks like but you probably need to
unprotect the sheet and protect it again in your macro something like:

ActiveSheet.Unprotect Password:="thepassword"
'rest of code
ActiveSheet.Protect Password:="thepassword"

Hope this helps
Rowan

"Cathy Landry" wrote:

Larry, Thank you for the input. The code did work, but I do have another
small problem. I used the code as a macro and assigned it to a button.
Ideally, we want users to be able to click the button to generate a
po#......which it does, but we also want the cell locked so they cannot
change the number or create their own. When the macro is run a box pops up
asking for a password as the cell has been locked. Is there a way to put
that into the code so the macro will run and not generate that message?

Thank you
Cathy



  #6   Report Post  
Cathy Landry
 
Posts: n/a
Default

Thank you! You have all been very helpful.

"Larry E" wrote:

You might want to check out "Mr. Excel" at www.mrexcel.com it's a great place
to post questions and problems. They also have some books and videos that
you might find useful.

Larry

"Cathy Landry" wrote:

Thank you all for your help! Is there a class (online) that teaches the
novice in Visual Basic?

Cathy

"Rowan" wrote:

I don't know what the original code looks like but you probably need to
unprotect the sheet and protect it again in your macro something like:

ActiveSheet.Unprotect Password:="thepassword"
'rest of code
ActiveSheet.Protect Password:="thepassword"

Hope this helps
Rowan

"Cathy Landry" wrote:

Larry, Thank you for the input. The code did work, but I do have another
small problem. I used the code as a macro and assigned it to a button.
Ideally, we want users to be able to click the button to generate a
po#......which it does, but we also want the cell locked so they cannot
change the number or create their own. When the macro is run a box pops up
asking for a password as the cell has been locked. Is there a way to put
that into the code so the macro will run and not generate that message?

Thank you
Cathy

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 assign sequential numbers in an Excel 2003 PO template? skiusa Excel Worksheet Functions 1 March 28th 05 10:57 PM
In Excel, I want to have all telephone numbers display in the sam. Fluffy from Wisconsin Excel Worksheet Functions 7 March 18th 05 02:05 AM
Excel countif based on size of numbers in one column in Access Kristjan_Thor Excel Worksheet Functions 3 March 17th 05 10:21 PM
Numbers after decimal point excel to word mail merge Andy P Excel Worksheet Functions 1 March 15th 05 11:48 AM
how do i set up to auto detect duplicated numbers in an excel fiel Peabody Excel Discussion (Misc queries) 1 December 15th 04 08:01 AM


All times are GMT +1. The time now is 09:15 AM.

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"