Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 103
Default Getting Cell value to another worksheet

I am trying to get a workbook that when it reaches 80 sheets it will take the
value from the last sheet and place it in a cell on the 1st sheet, sheets 2,
3, 4 and 5 are hidden, then the workbook will take sheets 6 through 80 and
delete them and the user can continue and create new worksheets beginning
with the ending value from the previous workbook. Any suggestions?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Getting Cell value to another worksheet

Here is code from VBA help

Occurs when a new sheet is created in the workbook.

Private Sub Workbook_NewSheet(ByVal Sh As Object)
Sh The new sheet. Can be a Worksheet or Chart object.

Example
This example moves new sheets to the end of the workbook.

Private Sub Workbook_NewSheet(ByVal Sh as Object)
Sh.Move After:= Sheets(Sheets.Count)
End Sub



"jnf40" wrote:

I am trying to get a workbook that when it reaches 80 sheets it will take the
value from the last sheet and place it in a cell on the 1st sheet, sheets 2,
3, 4 and 5 are hidden, then the workbook will take sheets 6 through 80 and
delete them and the user can continue and create new worksheets beginning
with the ending value from the previous workbook. Any suggestions?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 103
Default Getting Cell value to another worksheet

Thanks for the response but I already have that part working, below is what I
am trying to do now.

I am trying to get a workbook that when it reaches 80 sheets it will
automatically take the value from the last sheet, this value is derived
from a formula in that cell, and place it in a cell on the 1st sheet, sheets
2, 3, 4 and 5 are hidden, then the workbook will take sheets 6 through 80 and
delete them and the user can continue and create new worksheets beginning
with the ending value from the previous workbook.

"Joel" wrote:

Here is code from VBA help

Occurs when a new sheet is created in the workbook.

Private Sub Workbook_NewSheet(ByVal Sh As Object)
Sh The new sheet. Can be a Worksheet or Chart object.

Example
This example moves new sheets to the end of the workbook.

Private Sub Workbook_NewSheet(ByVal Sh as Object)
Sh.Move After:= Sheets(Sheets.Count)
End Sub



"jnf40" wrote:

I am trying to get a workbook that when it reaches 80 sheets it will take the
value from the last sheet and place it in a cell on the 1st sheet, sheets 2,
3, 4 and 5 are hidden, then the workbook will take sheets 6 through 80 and
delete them and the user can continue and create new worksheets beginning
with the ending value from the previous workbook. Any suggestions?

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Getting Cell value to another worksheet

something like this

Sub Workbook_NewSheet(ByVal Sh As Object)
If Worksheets.Count = 80 Then

Worksheets(Worksheets.Count - 1).Range("A1:B7").Copy _
Destination:=Worksheets(1).Range("A1")

For sheetcount = Worksheets.Count To 6 Step -1

Worksheets(sheetcount).Delete
Next sheetcount
End If
End Sub


"jnf40" wrote:

Thanks for the response but I already have that part working, below is what I
am trying to do now.

I am trying to get a workbook that when it reaches 80 sheets it will
automatically take the value from the last sheet, this value is derived
from a formula in that cell, and place it in a cell on the 1st sheet, sheets
2, 3, 4 and 5 are hidden, then the workbook will take sheets 6 through 80 and
delete them and the user can continue and create new worksheets beginning
with the ending value from the previous workbook.

"Joel" wrote:

Here is code from VBA help

Occurs when a new sheet is created in the workbook.

Private Sub Workbook_NewSheet(ByVal Sh As Object)
Sh The new sheet. Can be a Worksheet or Chart object.

Example
This example moves new sheets to the end of the workbook.

Private Sub Workbook_NewSheet(ByVal Sh as Object)
Sh.Move After:= Sheets(Sheets.Count)
End Sub



"jnf40" wrote:

I am trying to get a workbook that when it reaches 80 sheets it will take the
value from the last sheet and place it in a cell on the 1st sheet, sheets 2,
3, 4 and 5 are hidden, then the workbook will take sheets 6 through 80 and
delete them and the user can continue and create new worksheets beginning
with the ending value from the previous workbook. Any suggestions?

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 103
Default Getting Cell value to another worksheet

I'm getting an error message, do I need to declare sheetcount, and if so as
what?


"Joel" wrote:

something like this

Sub Workbook_NewSheet(ByVal Sh As Object)
If Worksheets.Count = 80 Then

Worksheets(Worksheets.Count - 1).Range("A1:B7").Copy _
Destination:=Worksheets(1).Range("A1")

For sheetcount = Worksheets.Count To 6 Step -1

Worksheets(sheetcount).Delete
Next sheetcount
End If
End Sub


"jnf40" wrote:

Thanks for the response but I already have that part working, below is what I
am trying to do now.

I am trying to get a workbook that when it reaches 80 sheets it will
automatically take the value from the last sheet, this value is derived
from a formula in that cell, and place it in a cell on the 1st sheet, sheets
2, 3, 4 and 5 are hidden, then the workbook will take sheets 6 through 80 and
delete them and the user can continue and create new worksheets beginning
with the ending value from the previous workbook.

"Joel" wrote:

Here is code from VBA help

Occurs when a new sheet is created in the workbook.

Private Sub Workbook_NewSheet(ByVal Sh As Object)
Sh The new sheet. Can be a Worksheet or Chart object.

Example
This example moves new sheets to the end of the workbook.

Private Sub Workbook_NewSheet(ByVal Sh as Object)
Sh.Move After:= Sheets(Sheets.Count)
End Sub



"jnf40" wrote:

I am trying to get a workbook that when it reaches 80 sheets it will take the
value from the last sheet and place it in a cell on the 1st sheet, sheets 2,
3, 4 and 5 are hidden, then the workbook will take sheets 6 through 80 and
delete them and the user can continue and create new worksheets beginning
with the ending value from the previous workbook. Any suggestions?



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Getting Cell value to another worksheet

If you have an "Option Explicit" statement then you need to declare the
variable

Dim sheetcount as integer

The macro need to be place on the ThisWorkbook VBA sheet.

"jnf40" wrote:

I'm getting an error message, do I need to declare sheetcount, and if so as
what?


"Joel" wrote:

something like this

Sub Workbook_NewSheet(ByVal Sh As Object)
If Worksheets.Count = 80 Then

Worksheets(Worksheets.Count - 1).Range("A1:B7").Copy _
Destination:=Worksheets(1).Range("A1")

For sheetcount = Worksheets.Count To 6 Step -1

Worksheets(sheetcount).Delete
Next sheetcount
End If
End Sub


"jnf40" wrote:

Thanks for the response but I already have that part working, below is what I
am trying to do now.

I am trying to get a workbook that when it reaches 80 sheets it will
automatically take the value from the last sheet, this value is derived
from a formula in that cell, and place it in a cell on the 1st sheet, sheets
2, 3, 4 and 5 are hidden, then the workbook will take sheets 6 through 80 and
delete them and the user can continue and create new worksheets beginning
with the ending value from the previous workbook.

"Joel" wrote:

Here is code from VBA help

Occurs when a new sheet is created in the workbook.

Private Sub Workbook_NewSheet(ByVal Sh As Object)
Sh The new sheet. Can be a Worksheet or Chart object.

Example
This example moves new sheets to the end of the workbook.

Private Sub Workbook_NewSheet(ByVal Sh as Object)
Sh.Move After:= Sheets(Sheets.Count)
End Sub



"jnf40" wrote:

I am trying to get a workbook that when it reaches 80 sheets it will take the
value from the last sheet and place it in a cell on the 1st sheet, sheets 2,
3, 4 and 5 are hidden, then the workbook will take sheets 6 through 80 and
delete them and the user can continue and create new worksheets beginning
with the ending value from the previous workbook. Any suggestions?

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 103
Default Getting Cell value to another worksheet

Here is the code I am using with your code

Private Sub UnhideSheets()
Dim sht As Object
Dim f As Worksheet
Application.ScreenUpdating = False
ActiveWorkbook.Unprotect Password:="csb"
If ThisWorkbook.Sheets.Count = 80 Then
For Each sht In ThisWorkbook.Sheets
sht.Visible = xlSheetVisible
sht.Unprotect Password:="csb"
Next sht
ThisWorkbook.Sheets("Macros").Visible = False
ThisWorkbook.Sheets("Save Me").Visible = False
ThisWorkbook.Sheets("CSB Form 1257").Select
ThisWorkbook.Sheets("CSB Form 1257").Protect Password:="csb"
ThisWorkbook.Sheets("CSB Form 1257").Visible = False
ThisWorkbook.Sheets("CSB Form 12572").Select
ThisWorkbook.Sheets("CSB Form 12572").Protect Password:="csb"
ThisWorkbook.Sheets("CSB Form 12572").Visible = False
ThisWorkbook.Sheets("Create Pay Report").Select
ActiveSheet.CommandButton14.Enabled = False
ActiveSheet.CommandButton14.Visible = True
ActiveSheet.CommandButton13.Enabled = False
ActiveSheet.CommandButton13.Visible = False
ActiveSheet.CommandButton15.Enabled = False
ActiveSheet.CommandButton15.Visible = False
ActiveSheet.CommandButton17.Enabled = True
MsgBox "You Must Create a New Workbook"
Worksheets(Worksheets.Count - 1).Range("av57:bc57").Copy _
Destination:=Worksheets(1).Range("v34")
Range("v34:ae34").Select
Application.CutCopyMode = False
Selection.Merge
Worksheets(Worksheets.Count - 1).Range("bb62:bd62").Copy _
Destination:=Worksheets(1).Range("as34")
Range("as34:bb34").Select
Application.CutCopyMode = False
Selection.Merge
Range("date").Select
For sheetcount = Worksheets.Count To 6 Step -1
Worksheets(sheetcount).Delete
Next sheetcount
ThisWorkbook.Sheets("Create Pay Report").Protect Password:="csb"
ElseIf ThisWorkbook.Sheets.Count 5 Then
For Each sht In ThisWorkbook.Sheets
sht.Visible = xlSheetVisible
sht.Protect Password:="csb"
Next sht
For Each f In ActiveWorkbook.Worksheets
If f.Name = Sheets("Create Pay Report").Range("wksname") Then
f.Select
'flag = True
Exit For
End If
Next f
ThisWorkbook.Sheets("Create Pay Report").Visible = False
ElseIf ThisWorkbook.Sheets.Count = 5 Then
ThisWorkbook.Sheets("Create Pay Report").Visible = True
ThisWorkbook.Sheets("Create Pay Report").Protect Password:="csb"
End If

ThisWorkbook.Sheets("Macros").Visible = False
ThisWorkbook.Sheets("Save Me").Visible = False
ThisWorkbook.Sheets("CSB Form 1257").Visible = False
ThisWorkbook.Sheets("CSB Form 12572").Visible = False

ActiveWorkbook.Protect Password:="csb"
Application.ScreenUpdating = True

End Sub


"Joel" wrote:

something like this

Sub Workbook_NewSheet(ByVal Sh As Object)
If Worksheets.Count = 80 Then

Worksheets(Worksheets.Count - 1).Range("A1:B7").Copy _
Destination:=Worksheets(1).Range("A1")

For sheetcount = Worksheets.Count To 6 Step -1

Worksheets(sheetcount).Delete
Next sheetcount
End If
End Sub


"jnf40" wrote:

Thanks for the response but I already have that part working, below is what I
am trying to do now.

I am trying to get a workbook that when it reaches 80 sheets it will
automatically take the value from the last sheet, this value is derived
from a formula in that cell, and place it in a cell on the 1st sheet, sheets
2, 3, 4 and 5 are hidden, then the workbook will take sheets 6 through 80 and
delete them and the user can continue and create new worksheets beginning
with the ending value from the previous workbook.

"Joel" wrote:

Here is code from VBA help

Occurs when a new sheet is created in the workbook.

Private Sub Workbook_NewSheet(ByVal Sh As Object)
Sh The new sheet. Can be a Worksheet or Chart object.

Example
This example moves new sheets to the end of the workbook.

Private Sub Workbook_NewSheet(ByVal Sh as Object)
Sh.Move After:= Sheets(Sheets.Count)
End Sub



"jnf40" wrote:

I am trying to get a workbook that when it reaches 80 sheets it will take the
value from the last sheet and place it in a cell on the 1st sheet, sheets 2,
3, 4 and 5 are hidden, then the workbook will take sheets 6 through 80 and
delete them and the user can continue and create new worksheets beginning
with the ending value from the previous workbook. Any suggestions?

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
Can I click on a cell on one worksheet and make it take me to another worksheet steve12345 New Users to Excel 7 November 5th 12 06:45 PM
copy cell from one worksheet to another worksheet in exel luvs_choc8 Excel Discussion (Misc queries) 1 July 10th 07 04:16 PM
link a cell in the 'Master' worksheet list to a 'Detail' worksheet Paul Condron Excel Programming 12 July 16th 06 10:41 PM
How can I link cell colours from worksheet to worksheet/workbook? Evelyn Excel Worksheet Functions 1 July 5th 05 09:16 PM
selecting cell range in other worksheet without switching to worksheet suzetter[_4_] Excel Programming 4 June 22nd 05 08:55 PM


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

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"