Solved

new sheet adds number from last sheet

Posted on 2011-02-24
7
277 Views
Last Modified: 2012-06-27
i need a code the creates a new sheet but the copies the numbers from the last sheet i created..
0
Comment
Question by:joshuajoseph09
7 Comments
 
LVL 6

Expert Comment

by:FernandoFernandes
ID: 34974136
why dont you right click on the sheet tab and select create a copy ?
0
 
LVL 65

Expert Comment

by:RobSampson
ID: 34974346
Hi, what "numbers" are you talking about?  Incrementing the sheet name, or copying data on the sheet?

Rob.
0
 
LVL 30

Expert Comment

by:SiddharthRout
ID: 34974549
joshuajoseph09: A sample sheet of Before and After scenario will help for a speedy solution :)

Sid
0
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 

Author Comment

by:joshuajoseph09
ID: 34975803
i have a button that creates a new sheet, with todays date. i need a code to copy over a row of numbers from the old sheet and put them into the new
0
 
LVL 65

Expert Comment

by:RobSampson
ID: 34975864
So is the old sheet just the sheet immediately before the current one?

Something like this might work:

dteToday = InputBox("Enter todays date:")
ActiveWorkbook.Sheets.Add , ActiveWorkbook.Sheets(ActiveWorkbook.Sheets.Count)
Set objNewSheet = ActiveWorkbook.Sheets(ActiveWorkbook.Sheets.Count)
objNewSheet.Name = dteToday
Set objPreviousSheet = ActiveWorkbook.Sheets(ActiveWorkbook.Sheets.Count - 1)
objPreviousSheet.Range("A1:Z1").Copy objNewSheet.Range("A1")


Regards,

Rob.
0
 

Author Comment

by:joshuajoseph09
ID: 34976698
i need it more like this. it needs to copy only the active sheet and make a new sheet and copy over the old data
dteToday = InputBox("Enter todays date:")
ActiveSheet.Select.Copy , ActiveSheet(ActiveSheet.Count)
Set objNewSheet = ActiveSheets(ActiveSheet.Count)
objNewSheet.Name = dteToday
Set objPreviousSheets = ActiveSheet(ActiveSheet.Count - 1)
objPreviousSheets.Range("F11:F16,H11:H16,J11:J16,L11:L16,N11:N16,P11:P16,R11:R16").Copy objNewSheet.Range("AA11:AG16")

Open in new window

0
 
LVL 65

Accepted Solution

by:
RobSampson earned 500 total points
ID: 34976738
I haven't tested it, but try this.

Regards,

Rob.
dteToday = InputBox("Enter todays date:")
Set objPreviousSheet = ActiveSheet
objPreviousSheet.Copy , ActiveWorkbook.Sheets(ActiveWorkbook.Sheets.Count)
Set objNewSheet = ActiveWorkbook.Sheets(ActiveWorkbook.Sheets.Count)
objNewSheet.Name = dteToday
objPreviousSheet.Range("F11:F16,H11:H16,J11:J16,L11:L16,N11:N16,P11:P16,R11:R16").Copy objNewSheet.Range("AA11:AG16")

Open in new window

0

Featured Post

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question