Solved

new sheet adds number from last sheet

Posted on 2011-02-24
7
289 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

 

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

With User Account Control (UAC) enabled in Windows 7, one needs to open an elevated Command Prompt in order to run scripts under administrative privileges. Although the elevated Command Prompt accomplishes the task, the question How to run as script…
How to get Spreadsheet Compare 2016 working with the 64 bit version of Office 2016
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.

627 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