Excel/print macro

Advertisement


Question
macrodos,
Hello, I have a print macro I need to adapt. I hope you can help with it. What I would like to do is use this print macro to not only print sheet2 but then print two other sheets each time the date changes the same as it does for sheet two. In other words what I am trying to do is enter date for sheet2 which will update sheet2 which in turn updates sheet1 and sheet3 all of which have thier date in the same cell as sheet2 (A1). I would like it to print sheet2 then sheet1 then sheet3 before it changes the date automatically then print sheet2, 1, 3, so on depending how many days are selected from n2. the following is the code I am currently using.

Sub PrintDoc()
With ActiveSheet  
  For NumDays = 0 To .Range("N2") - 1   
      .Range("A1").Value = .Range("N1") + NumDays  
      If .Range("N3") = "Yes" Then  ' check if we want to preview the print or not
         ActiveWindow.SelectedSheets.PrintPreview  'if yes then print sheet with preview
         GoTo NextNum  'then goto the label NextNum so as to skip the print direct line
      End If  
         ActiveWindow.SelectedSheets.PrintOut        
NextNum:
  Next NumDays  
End With        
End Sub     
I am assuming my problem lies with activesheet but I have no idea how to change active sheet in mid stream to catch each tab before changing date on sheet2 and continue. I tried to copy paste macro to the other sheets to run seperately but no matter what I put in the date range of N! the data stays the same as on sheet 2 even though the date changes on sheets 1 and 3.
John

Answer
I sent you mail, pass the file to view and return with the solution.
The problem is in active sheet, you should use a variable to refer to a sheet is used for example

sheets ("sheet1"). Range ("N1")

visit http://www.programarexcel.blogspot.com find many macros that reference cells and you can use for example, the site can be translated in several languages ​​with a language selector which has built through google traslate

Please before scoring, I want to ask you to be satisfied with the answer allexpert.com ranking is important to me.
About Excel
This topic answers questions related to Microsoft Excel spreadsheet (or workbook) stand-alone or Mircrosoft Office Excel including Excel 2003, Excel 2007, Office 2000, and Office XP. You can get Excel help on Excel formulas(or functions), Excell macros, charting in Excel, advanced features, and the general use of Excel. This does not provide a general Excel tutorial nor the basics of using a spreadsheet. It provides specific answers to using Microsoft Excel only. If you do not see your Excel question answered in this area then please ask an Excel question here

Excel

All Answers


Answers by Expert:


Ask Experts

Volunteer


marcrodos

Expertise

Expert programming macros or visual basic VBA that can help automate your Excel spreadsheets using VBA programming or macros to excel, forms and other procedures related to Macros. I also have an excellent command of Excel in almost its entirety, formulas, graphs, dynamic tables. In http://programarexcel.blogspot.com o www.programarexcel.com examples can download free excel macros programmed in VBA, macros can be downloaded and adapted to the project that you're doing to automate excel www.programarexcel.com

Experience

For several years, use Microsoft Excel on a daily basis, more specifically in my work, which is why over several years I have compiled a wealth of knowledge about their operation, adding to the basic operation of coding excel VBA macros to automate repetitive tasks . I serve as an expert in excel also in www.todoexpertos.com site, which I enjoy a great reputation. In http://programarexcel.blogspot.com o www.programarexcel.com examples can download free excel macros programmed in VBA, macros can be downloaded and adapted to the project that you're doing to automate excel www.programarexcel.com

Organizations
http://www.programarexcel.blogspot.com http://www.programarexcel.com

Publications
In public http://www.programarexcel.com o www.programarexcel.com continuously macro examples that readers can download for free and adapt to the needs of each project in excel that has the web page visitor

Education/Credentials
My profession's is a Chartered Accountant with experience in Excel, especially in VBA or macro programming, but also in the formulas and everything related to excel, I graduated several years ago at the National University of Cordoba, now I practice my profession in which a basic tool is excel. www.programarexcel.com

Awards and Honors
http://www.programarexcel.blogspot.com http://www.programarexcel.com

Past/Present Clients
http://www.programarexcel.blogspot.com http://www.programarexcel.com

©2016 About.com. All rights reserved.