Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
WYN
 
Posts: n/a
Default help with protect sheet

good day all,i have a invoice template with a macro set to number them.when i
protect the sheet the macros stops working.any suggestions? thx wyn
--
wynb
  #2   Report Post  
Gord Dibben
 
Posts: n/a
Default

WYN

Unprotect the sheet, do your stuff then reprotect.

Sub Numberit()
ActiveSheet.Unprotect Password:="justme"

'your code or macro name goes here

ActiveSheet.Protect Password:="justme", DrawingObjects:=True, _
Contents:=True, Scenarios:=True
End Sub


Gord Dibben Excel MVP

On Wed, 16 Feb 2005 15:55:01 -0800, WYN wrote:

good day all,i have a invoice template with a macro set to number them.when i
protect the sheet the macros stops working.any suggestions? thx wyn


  #3   Report Post  
WYN
 
Posts: n/a
Default

hi gord,my existing code is under this workbook.should i put the code in a
new module,worksheet or combine it under workbook? thx wyn

"Gord Dibben" wrote:

WYN

Unprotect the sheet, do your stuff then reprotect.

Sub Numberit()
ActiveSheet.Unprotect Password:="justme"

'your code or macro name goes here

ActiveSheet.Protect Password:="justme", DrawingObjects:=True, _
Contents:=True, Scenarios:=True
End Sub


Gord Dibben Excel MVP

On Wed, 16 Feb 2005 15:55:01 -0800, WYN wrote:

good day all,i have a invoice template with a macro set to number them.when i
protect the sheet the macros stops working.any suggestions? thx wyn



  #4   Report Post  
Gord Dibben
 
Posts: n/a
Default

By "this workbook" do you mean you have Workbook_Open or Activate code that
runs when the workbook is opened or activated?

It could be inserted around the existing code in that case.

You could also combine it with your code and stick it in a worksheet_activate
routine.

If you have trouble, post your current code and I'm sure we can figure out
where to add it.


Gord

On Wed, 16 Feb 2005 18:19:04 -0800, WYN wrote:

hi gord,my existing code is under this workbook.should i put the code in a
new module,worksheet or combine it under workbook? thx wyn

"Gord Dibben" wrote:

WYN

Unprotect the sheet, do your stuff then reprotect.

Sub Numberit()
ActiveSheet.Unprotect Password:="justme"

'your code or macro name goes here

ActiveSheet.Protect Password:="justme", DrawingObjects:=True, _
Contents:=True, Scenarios:=True
End Sub


Gord Dibben Excel MVP

On Wed, 16 Feb 2005 15:55:01 -0800, WYN wrote:

good day all,i have a invoice template with a macro set to number them.when i
protect the sheet the macros stops working.any suggestions? thx wyn




  #5   Report Post  
WYN
 
Posts: n/a
Default

Private Sub Workbook_Open()
Const sAPPLICATION As String = "Excel"
Const sSECTION As String = "Invoice"
Const sKEY As String = "Invoice_key"
Const nDEFAULT As Long = 1&
Dim nNumber As Long

With ThisWorkbook.Sheets("Invoice")
With .Range("q5")
If IsEmpty(.Value) Then
.Value = Date
.NumberFormat = "dd mmm yyyy"
End If
End With
With .Range("n1")
If IsEmpty(.Value) Then
nNumber = GetSetting(sAPPLICATION, sSECTION, sKEY,
nDEFAULT)
.NumberFormat = "@"
.Value = Format(nNumber, "0000")
SaveSetting sAPPLICATION, sSECTION, sKEY, nNumber + 1&
End If
End With
End With
End Sub
hi gord,here is the coe i am using.thx wynb



"Gord Dibben" wrote:

By "this workbook" do you mean you have Workbook_Open or Activate code that
runs when the workbook is opened or activated?

It could be inserted around the existing code in that case.

You could also combine it with your code and stick it in a worksheet_activate
routine.

If you have trouble, post your current code and I'm sure we can figure out
where to add it.


Gord

On Wed, 16 Feb 2005 18:19:04 -0800, WYN wrote:

hi gord,my existing code is under this workbook.should i put the code in a
new module,worksheet or combine it under workbook? thx wyn

"Gord Dibben" wrote:

WYN

Unprotect the sheet, do your stuff then reprotect.

Sub Numberit()
ActiveSheet.Unprotect Password:="justme"

'your code or macro name goes here

ActiveSheet.Protect Password:="justme", DrawingObjects:=True, _
Contents:=True, Scenarios:=True
End Sub


Gord Dibben Excel MVP

On Wed, 16 Feb 2005 15:55:01 -0800, WYN wrote:

good day all,i have a invoice template with a macro set to number them.when i
protect the sheet the macros stops working.any suggestions? thx wyn






  #6   Report Post  
Gord Dibben
 
Posts: n/a
Default

Try this.

Remove the

Private Sub Workbook_Open()
Const sAPPLICATION As String = "Excel"
Const sSECTION As String = "Invoice"
Const sKEY As String = "Invoice_key"
Const nDEFAULT As Long = 1&
Dim nNumber As Long

With ThisWorkbook.Sheets("Invoice")
ActiveSheet.Unprotect Password:="justme" 'or whatever pword is

With .Range("q5")
If IsEmpty(.Value) Then
.Value = Date
.NumberFormat = "dd mmm yyyy"
End If
End With
With .Range("n1")
If IsEmpty(.Value) Then
nNumber = GetSetting(sAPPLICATION, sSECTION, sKEY, _
nDEFAULT)
.NumberFormat = "@"
.Value = Format(nNumber, "0000")
SaveSetting sAPPLICATION, sSECTION, sKEY, nNumber + 1&
End If
End With
End With
ActiveSheet.Protect Password:="justme", DrawingObjects:=True, _
Contents:=True, Scenarios:=True

End Sub


Gord
  #7   Report Post  
Dave Peterson
 
Posts: n/a
Default

This might get you closer...

Option Explicit
Private Sub Workbook_Open()
Const sAPPLICATION As String = "Excel"
Const sSECTION As String = "Invoice"
Const sKEY As String = "Invoice_key"
Const nDEFAULT As Long = 1&
Dim nNumber As Long

With ThisWorkbook.Sheets("Invoice")
.Unprotect Password:="hi!"
With .Range("q5")
If IsEmpty(.Value) Then
.Value = Date
.NumberFormat = "dd mmm yyyy"
End If
End With
With .Range("n1")
If IsEmpty(.Value) Then
nNumber = GetSetting(sAPPLICATION, sSECTION, sKEY, nDEFAULT)
.NumberFormat = "@"
.Value = Format(nNumber, "0000")
SaveSetting sAPPLICATION, sSECTION, sKEY, nNumber + 1&
End If
End With
.Protect Password:="hi!"
End With
End Sub



WYN wrote:

Private Sub Workbook_Open()
Const sAPPLICATION As String = "Excel"
Const sSECTION As String = "Invoice"
Const sKEY As String = "Invoice_key"
Const nDEFAULT As Long = 1&
Dim nNumber As Long

With ThisWorkbook.Sheets("Invoice")
With .Range("q5")
If IsEmpty(.Value) Then
.Value = Date
.NumberFormat = "dd mmm yyyy"
End If
End With
With .Range("n1")
If IsEmpty(.Value) Then
nNumber = GetSetting(sAPPLICATION, sSECTION, sKEY,
nDEFAULT)
.NumberFormat = "@"
.Value = Format(nNumber, "0000")
SaveSetting sAPPLICATION, sSECTION, sKEY, nNumber + 1&
End If
End With
End With
End Sub
hi gord,here is the coe i am using.thx wynb

"Gord Dibben" wrote:

By "this workbook" do you mean you have Workbook_Open or Activate code that
runs when the workbook is opened or activated?

It could be inserted around the existing code in that case.

You could also combine it with your code and stick it in a worksheet_activate
routine.

If you have trouble, post your current code and I'm sure we can figure out
where to add it.


Gord

On Wed, 16 Feb 2005 18:19:04 -0800, WYN wrote:

hi gord,my existing code is under this workbook.should i put the code in a
new module,worksheet or combine it under workbook? thx wyn

"Gord Dibben" wrote:

WYN

Unprotect the sheet, do your stuff then reprotect.

Sub Numberit()
ActiveSheet.Unprotect Password:="justme"

'your code or macro name goes here

ActiveSheet.Protect Password:="justme", DrawingObjects:=True, _
Contents:=True, Scenarios:=True
End Sub


Gord Dibben Excel MVP

On Wed, 16 Feb 2005 15:55:01 -0800, WYN wrote:

good day all,i have a invoice template with a macro set to number them.when i
protect the sheet the macros stops working.any suggestions? thx wyn





--

Dave Peterson
  #8   Report Post  
Gord Dibben
 
Posts: n/a
Default

So much more concise<g

Just for interest. I stuck my re-protect after the last End With.

Without testing, does it make a difference?


Gord

On Thu, 17 Feb 2005 18:28:44 -0600, Dave Peterson
wrote:

This might get you closer...

Option Explicit
Private Sub Workbook_Open()
Const sAPPLICATION As String = "Excel"
Const sSECTION As String = "Invoice"
Const sKEY As String = "Invoice_key"
Const nDEFAULT As Long = 1&
Dim nNumber As Long

With ThisWorkbook.Sheets("Invoice")
.Unprotect Password:="hi!"
With .Range("q5")
If IsEmpty(.Value) Then
.Value = Date
.NumberFormat = "dd mmm yyyy"
End If
End With
With .Range("n1")
If IsEmpty(.Value) Then
nNumber = GetSetting(sAPPLICATION, sSECTION, sKEY, nDEFAULT)
.NumberFormat = "@"
.Value = Format(nNumber, "0000")
SaveSetting sAPPLICATION, sSECTION, sKEY, nNumber + 1&
End If
End With
.Protect Password:="hi!"
End With
End Sub



WYN wrote:

Private Sub Workbook_Open()
Const sAPPLICATION As String = "Excel"
Const sSECTION As String = "Invoice"
Const sKEY As String = "Invoice_key"
Const nDEFAULT As Long = 1&
Dim nNumber As Long

With ThisWorkbook.Sheets("Invoice")
With .Range("q5")
If IsEmpty(.Value) Then
.Value = Date
.NumberFormat = "dd mmm yyyy"
End If
End With
With .Range("n1")
If IsEmpty(.Value) Then
nNumber = GetSetting(sAPPLICATION, sSECTION, sKEY,
nDEFAULT)
.NumberFormat = "@"
.Value = Format(nNumber, "0000")
SaveSetting sAPPLICATION, sSECTION, sKEY, nNumber + 1&
End If
End With
End With
End Sub
hi gord,here is the coe i am using.thx wynb

"Gord Dibben" wrote:

By "this workbook" do you mean you have Workbook_Open or Activate code that
runs when the workbook is opened or activated?

It could be inserted around the existing code in that case.

You could also combine it with your code and stick it in a worksheet_activate
routine.

If you have trouble, post your current code and I'm sure we can figure out
where to add it.


Gord

On Wed, 16 Feb 2005 18:19:04 -0800, WYN wrote:

hi gord,my existing code is under this workbook.should i put the code in a
new module,worksheet or combine it under workbook? thx wyn

"Gord Dibben" wrote:

WYN

Unprotect the sheet, do your stuff then reprotect.

Sub Numberit()
ActiveSheet.Unprotect Password:="justme"

'your code or macro name goes here

ActiveSheet.Protect Password:="justme", DrawingObjects:=True, _
Contents:=True, Scenarios:=True
End Sub


Gord Dibben Excel MVP

On Wed, 16 Feb 2005 15:55:01 -0800, WYN wrote:

good day all,i have a invoice template with a macro set to number them.when i
protect the sheet the macros stops working.any suggestions? thx wyn





  #9   Report Post  
Dave Peterson
 
Posts: n/a
Default

But your code unprotected/protected the activesheet.

By using the with/end with structure, I was unprotecting/protecting the
"Invoice" sheet.



Gord Dibben wrote:

So much more concise<g

Just for interest. I stuck my re-protect after the last End With.

Without testing, does it make a difference?

Gord

On Thu, 17 Feb 2005 18:28:44 -0600, Dave Peterson
wrote:

This might get you closer...

Option Explicit
Private Sub Workbook_Open()
Const sAPPLICATION As String = "Excel"
Const sSECTION As String = "Invoice"
Const sKEY As String = "Invoice_key"
Const nDEFAULT As Long = 1&
Dim nNumber As Long

With ThisWorkbook.Sheets("Invoice")
.Unprotect Password:="hi!"
With .Range("q5")
If IsEmpty(.Value) Then
.Value = Date
.NumberFormat = "dd mmm yyyy"
End If
End With
With .Range("n1")
If IsEmpty(.Value) Then
nNumber = GetSetting(sAPPLICATION, sSECTION, sKEY, nDEFAULT)
.NumberFormat = "@"
.Value = Format(nNumber, "0000")
SaveSetting sAPPLICATION, sSECTION, sKEY, nNumber + 1&
End If
End With
.Protect Password:="hi!"
End With
End Sub



WYN wrote:

Private Sub Workbook_Open()
Const sAPPLICATION As String = "Excel"
Const sSECTION As String = "Invoice"
Const sKEY As String = "Invoice_key"
Const nDEFAULT As Long = 1&
Dim nNumber As Long

With ThisWorkbook.Sheets("Invoice")
With .Range("q5")
If IsEmpty(.Value) Then
.Value = Date
.NumberFormat = "dd mmm yyyy"
End If
End With
With .Range("n1")
If IsEmpty(.Value) Then
nNumber = GetSetting(sAPPLICATION, sSECTION, sKEY,
nDEFAULT)
.NumberFormat = "@"
.Value = Format(nNumber, "0000")
SaveSetting sAPPLICATION, sSECTION, sKEY, nNumber + 1&
End If
End With
End With
End Sub
hi gord,here is the coe i am using.thx wynb

"Gord Dibben" wrote:

By "this workbook" do you mean you have Workbook_Open or Activate code that
runs when the workbook is opened or activated?

It could be inserted around the existing code in that case.

You could also combine it with your code and stick it in a worksheet_activate
routine.

If you have trouble, post your current code and I'm sure we can figure out
where to add it.


Gord

On Wed, 16 Feb 2005 18:19:04 -0800, WYN wrote:

hi gord,my existing code is under this workbook.should i put the code in a
new module,worksheet or combine it under workbook? thx wyn

"Gord Dibben" wrote:

WYN

Unprotect the sheet, do your stuff then reprotect.

Sub Numberit()
ActiveSheet.Unprotect Password:="justme"

'your code or macro name goes here

ActiveSheet.Protect Password:="justme", DrawingObjects:=True, _
Contents:=True, Scenarios:=True
End Sub


Gord Dibben Excel MVP

On Wed, 16 Feb 2005 15:55:01 -0800, WYN wrote:

good day all,i have a invoice template with a macro set to number them.when i
protect the sheet the macros stops working.any suggestions? thx wyn





--

Dave Peterson
  #10   Report Post  
Gord Dibben
 
Posts: n/a
Default

Ah so.

Never even noticed the "Invoice" sheet was not active.

Getting worser and worser.

Maybe find a different hobby to go along with the golfing which lends itself
perfectly to my poor memory and inattention to detail.

I can turn in some amazingly low scores.


Gord

On Thu, 17 Feb 2005 18:49:40 -0600, Dave Peterson
wrote:

But your code unprotected/protected the activesheet.

By using the with/end with structure, I was unprotecting/protecting the
"Invoice" sheet.



Gord Dibben wrote:

So much more concise<g

Just for interest. I stuck my re-protect after the last End With.

Without testing, does it make a difference?

Gord

On Thu, 17 Feb 2005 18:28:44 -0600, Dave Peterson
wrote:

This might get you closer...

Option Explicit
Private Sub Workbook_Open()
Const sAPPLICATION As String = "Excel"
Const sSECTION As String = "Invoice"
Const sKEY As String = "Invoice_key"
Const nDEFAULT As Long = 1&
Dim nNumber As Long

With ThisWorkbook.Sheets("Invoice")
.Unprotect Password:="hi!"
With .Range("q5")
If IsEmpty(.Value) Then
.Value = Date
.NumberFormat = "dd mmm yyyy"
End If
End With
With .Range("n1")
If IsEmpty(.Value) Then
nNumber = GetSetting(sAPPLICATION, sSECTION, sKEY, nDEFAULT)
.NumberFormat = "@"
.Value = Format(nNumber, "0000")
SaveSetting sAPPLICATION, sSECTION, sKEY, nNumber + 1&
End If
End With
.Protect Password:="hi!"
End With
End Sub



WYN wrote:

Private Sub Workbook_Open()
Const sAPPLICATION As String = "Excel"
Const sSECTION As String = "Invoice"
Const sKEY As String = "Invoice_key"
Const nDEFAULT As Long = 1&
Dim nNumber As Long

With ThisWorkbook.Sheets("Invoice")
With .Range("q5")
If IsEmpty(.Value) Then
.Value = Date
.NumberFormat = "dd mmm yyyy"
End If
End With
With .Range("n1")
If IsEmpty(.Value) Then
nNumber = GetSetting(sAPPLICATION, sSECTION, sKEY,
nDEFAULT)
.NumberFormat = "@"
.Value = Format(nNumber, "0000")
SaveSetting sAPPLICATION, sSECTION, sKEY, nNumber + 1&
End If
End With
End With
End Sub
hi gord,here is the coe i am using.thx wynb

"Gord Dibben" wrote:

By "this workbook" do you mean you have Workbook_Open or Activate code that
runs when the workbook is opened or activated?

It could be inserted around the existing code in that case.

You could also combine it with your code and stick it in a worksheet_activate
routine.

If you have trouble, post your current code and I'm sure we can figure out
where to add it.


Gord

On Wed, 16 Feb 2005 18:19:04 -0800, WYN wrote:

hi gord,my existing code is under this workbook.should i put the code in a
new module,worksheet or combine it under workbook? thx wyn

"Gord Dibben" wrote:

WYN

Unprotect the sheet, do your stuff then reprotect.

Sub Numberit()
ActiveSheet.Unprotect Password:="justme"

'your code or macro name goes here

ActiveSheet.Protect Password:="justme", DrawingObjects:=True, _
Contents:=True, Scenarios:=True
End Sub


Gord Dibben Excel MVP

On Wed, 16 Feb 2005 15:55:01 -0800, WYN wrote:

good day all,i have a invoice template with a macro set to number them.when i
protect the sheet the macros stops working.any suggestions? thx wyn







  #11   Report Post  
WYN
 
Posts: n/a
Default

gentlemen that works perfectly.i thank you for your help. hey gord i see that
you must have the same golf rule book as me.count only the straight drives
and no more thah two puts. thanks again.wyn.

"Gord Dibben" wrote:

Ah so.

Never even noticed the "Invoice" sheet was not active.

Getting worser and worser.

Maybe find a different hobby to go along with the golfing which lends itself
perfectly to my poor memory and inattention to detail.

I can turn in some amazingly low scores.


Gord

On Thu, 17 Feb 2005 18:49:40 -0600, Dave Peterson
wrote:

But your code unprotected/protected the activesheet.

By using the with/end with structure, I was unprotecting/protecting the
"Invoice" sheet.



Gord Dibben wrote:

So much more concise<g

Just for interest. I stuck my re-protect after the last End With.

Without testing, does it make a difference?

Gord

On Thu, 17 Feb 2005 18:28:44 -0600, Dave Peterson
wrote:

This might get you closer...

Option Explicit
Private Sub Workbook_Open()
Const sAPPLICATION As String = "Excel"
Const sSECTION As String = "Invoice"
Const sKEY As String = "Invoice_key"
Const nDEFAULT As Long = 1&
Dim nNumber As Long

With ThisWorkbook.Sheets("Invoice")
.Unprotect Password:="hi!"
With .Range("q5")
If IsEmpty(.Value) Then
.Value = Date
.NumberFormat = "dd mmm yyyy"
End If
End With
With .Range("n1")
If IsEmpty(.Value) Then
nNumber = GetSetting(sAPPLICATION, sSECTION, sKEY, nDEFAULT)
.NumberFormat = "@"
.Value = Format(nNumber, "0000")
SaveSetting sAPPLICATION, sSECTION, sKEY, nNumber + 1&
End If
End With
.Protect Password:="hi!"
End With
End Sub



WYN wrote:

Private Sub Workbook_Open()
Const sAPPLICATION As String = "Excel"
Const sSECTION As String = "Invoice"
Const sKEY As String = "Invoice_key"
Const nDEFAULT As Long = 1&
Dim nNumber As Long

With ThisWorkbook.Sheets("Invoice")
With .Range("q5")
If IsEmpty(.Value) Then
.Value = Date
.NumberFormat = "dd mmm yyyy"
End If
End With
With .Range("n1")
If IsEmpty(.Value) Then
nNumber = GetSetting(sAPPLICATION, sSECTION, sKEY,
nDEFAULT)
.NumberFormat = "@"
.Value = Format(nNumber, "0000")
SaveSetting sAPPLICATION, sSECTION, sKEY, nNumber + 1&
End If
End With
End With
End Sub
hi gord,here is the coe i am using.thx wynb

"Gord Dibben" wrote:

By "this workbook" do you mean you have Workbook_Open or Activate code that
runs when the workbook is opened or activated?

It could be inserted around the existing code in that case.

You could also combine it with your code and stick it in a worksheet_activate
routine.

If you have trouble, post your current code and I'm sure we can figure out
where to add it.


Gord

On Wed, 16 Feb 2005 18:19:04 -0800, WYN wrote:

hi gord,my existing code is under this workbook.should i put the code in a
new module,worksheet or combine it under workbook? thx wyn

"Gord Dibben" wrote:

WYN

Unprotect the sheet, do your stuff then reprotect.

Sub Numberit()
ActiveSheet.Unprotect Password:="justme"

'your code or macro name goes here

ActiveSheet.Protect Password:="justme", DrawingObjects:=True, _
Contents:=True, Scenarios:=True
End Sub


Gord Dibben Excel MVP

On Wed, 16 Feb 2005 15:55:01 -0800, WYN wrote:

good day all,i have a invoice template with a macro set to number them.when i
protect the sheet the macros stops working.any suggestions? thx wyn






  #12   Report Post  
Dave Peterson
 
Posts: n/a
Default

I have that same ability in bowling.

(I'm not getting involved in this one <vbg!)



Gord Dibben wrote:

Ah so.

Never even noticed the "Invoice" sheet was not active.

Getting worser and worser.

Maybe find a different hobby to go along with the golfing which lends itself
perfectly to my poor memory and inattention to detail.

I can turn in some amazingly low scores.

Gord

  #13   Report Post  
Gord Dibben
 
Posts: n/a
Default

WYN

Glad to see Dave got you straightened out.

Yep. Ball in pocket after max allowed. Funny how those other guys won't let
me do that in competition.

Gord

On Thu, 17 Feb 2005 18:05:03 -0800, WYN wrote:

gentlemen that works perfectly.i thank you for your help. hey gord i see that
you must have the same golf rule book as me.count only the straight drives
and no more thah two puts. thanks again.wyn.

"Gord Dibben" wrote:

Ah so.

Never even noticed the "Invoice" sheet was not active.

Getting worser and worser.

Maybe find a different hobby to go along with the golfing which lends itself
perfectly to my poor memory and inattention to detail.

I can turn in some amazingly low scores.


Gord

On Thu, 17 Feb 2005 18:49:40 -0600, Dave Peterson
wrote:

But your code unprotected/protected the activesheet.

By using the with/end with structure, I was unprotecting/protecting the
"Invoice" sheet.



Gord Dibben wrote:

So much more concise<g

Just for interest. I stuck my re-protect after the last End With.

Without testing, does it make a difference?

Gord

On Thu, 17 Feb 2005 18:28:44 -0600, Dave Peterson
wrote:

This might get you closer...

Option Explicit
Private Sub Workbook_Open()
Const sAPPLICATION As String = "Excel"
Const sSECTION As String = "Invoice"
Const sKEY As String = "Invoice_key"
Const nDEFAULT As Long = 1&
Dim nNumber As Long

With ThisWorkbook.Sheets("Invoice")
.Unprotect Password:="hi!"
With .Range("q5")
If IsEmpty(.Value) Then
.Value = Date
.NumberFormat = "dd mmm yyyy"
End If
End With
With .Range("n1")
If IsEmpty(.Value) Then
nNumber = GetSetting(sAPPLICATION, sSECTION, sKEY, nDEFAULT)
.NumberFormat = "@"
.Value = Format(nNumber, "0000")
SaveSetting sAPPLICATION, sSECTION, sKEY, nNumber + 1&
End If
End With
.Protect Password:="hi!"
End With
End Sub



WYN wrote:

Private Sub Workbook_Open()
Const sAPPLICATION As String = "Excel"
Const sSECTION As String = "Invoice"
Const sKEY As String = "Invoice_key"
Const nDEFAULT As Long = 1&
Dim nNumber As Long

With ThisWorkbook.Sheets("Invoice")
With .Range("q5")
If IsEmpty(.Value) Then
.Value = Date
.NumberFormat = "dd mmm yyyy"
End If
End With
With .Range("n1")
If IsEmpty(.Value) Then
nNumber = GetSetting(sAPPLICATION, sSECTION, sKEY,
nDEFAULT)
.NumberFormat = "@"
.Value = Format(nNumber, "0000")
SaveSetting sAPPLICATION, sSECTION, sKEY, nNumber + 1&
End If
End With
End With
End Sub
hi gord,here is the coe i am using.thx wynb

"Gord Dibben" wrote:

By "this workbook" do you mean you have Workbook_Open or Activate code that
runs when the workbook is opened or activated?

It could be inserted around the existing code in that case.

You could also combine it with your code and stick it in a worksheet_activate
routine.

If you have trouble, post your current code and I'm sure we can figure out
where to add it.


Gord

On Wed, 16 Feb 2005 18:19:04 -0800, WYN wrote:

hi gord,my existing code is under this workbook.should i put the code in a
new module,worksheet or combine it under workbook? thx wyn

"Gord Dibben" wrote:

WYN

Unprotect the sheet, do your stuff then reprotect.

Sub Numberit()
ActiveSheet.Unprotect Password:="justme"

'your code or macro name goes here

ActiveSheet.Protect Password:="justme", DrawingObjects:=True, _
Contents:=True, Scenarios:=True
End Sub


Gord Dibben Excel MVP

On Wed, 16 Feb 2005 15:55:01 -0800, WYN wrote:

good day all,i have a invoice template with a macro set to number them.when i
protect the sheet the macros stops working.any suggestions? thx wyn







  #14   Report Post  
WYN
 
Posts: n/a
Default

yuo must have realy big pockets dave. wyn

"Dave Peterson" wrote:

I have that same ability in bowling.

(I'm not getting involved in this one <vbg!)



Gord Dibben wrote:

Ah so.

Never even noticed the "Invoice" sheet was not active.

Getting worser and worser.

Maybe find a different hobby to go along with the golfing which lends itself
perfectly to my poor memory and inattention to detail.

I can turn in some amazingly low scores.

Gord


  #15   Report Post  
Dave Peterson
 
Posts: n/a
Default

I deleted lots of responses. <vbg

WYN wrote:

yuo must have realy big pockets dave. wyn

"Dave Peterson" wrote:

I have that same ability in bowling.

(I'm not getting involved in this one <vbg!)



Gord Dibben wrote:

Ah so.

Never even noticed the "Invoice" sheet was not active.

Getting worser and worser.

Maybe find a different hobby to go along with the golfing which lends itself
perfectly to my poor memory and inattention to detail.

I can turn in some amazingly low scores.

Gord



--

Dave Peterson
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 protect work sheet against the "Delete" function? Kev Nurse Excel Discussion (Misc queries) 1 February 17th 05 03:01 AM
how to protect sheet from adding/deleting Scott Excel Discussion (Misc queries) 1 February 16th 05 05:21 PM
Protect Sheet > All sheets Adam Excel Discussion (Misc queries) 3 January 31st 05 04:37 PM
Variable validation-password protect sheet Marty Excel Worksheet Functions 0 January 26th 05 02:27 PM
Naming & renaming a sheet tab Cgbilliar Excel Worksheet Functions 1 November 7th 04 05:57 PM


All times are GMT +1. The time now is 04:14 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"