need a vbscript for multiple excel files

Author Message
vishalvijayan

  • Total Posts : 6
  • Scores: 0
  • Reward points : 0
  • Joined: 7/5/2010
  • Status: offline
need a vbscript for multiple excel files Wednesday, July 07, 2010 5:31 PM (permalink)
0
Hello,

I have a excel file with two sheets. 
Sheet1 (Workflow tracker) is used by operators to enter values, delivery periods, dates ect.
Sheet2 (Dashboard) is used to display a summary of the data in Sheet 1 for the Management guys.

Right now it is working fine with both the sheets in the same excel file.

What I want to do is to move sheet2 from excel file to a new excel file, so that there are 2 separate excel files. one for the operator and 2nd for the management guys.

Can anyone help me with the code, how to call the excel file from the 2nd excel file. Below is the code which is right now working with both the sheets in the same excel file.

Option Explicit

Dim TempVal As String

Private Sub Worksheet_Activate()

     Application.DisplayAlerts = False
     TempVal = Range("G5").Value
     Range("G5").Value = "Wait Refreshing Data"
     Application.ScreenUpdating = False
     If ActiveSheet.AutoFilterMode = False Then
          Range("A5:G65536").Select
          Selection.AutoFilter
     Else
          If ActiveSheet.FilterMode = True Then
               ActiveSheet.ShowAllData
          End If
     End If

     Range("A6").FormulaR1C1 = _
     "=IF(OR('Daily Workflow Tracker'!RC[20]>=3,'Daily Workflow Tracker'!RC[22]>0),'Daily Workflow Tracker'!RC,"""")"
     Range("B6").FormulaR1C1 = "=IF(RC[-1]<>"""",'Daily Workflow Tracker'!RC[5],"""")"
     Range("C6").FormulaR1C1 = "=IF(RC[-2]<>"""",'Daily Workflow Tracker'!RC[8],"""")"
     Range("D6").FormulaR1C1 = "=IF(RC[-3]<>"""",'Daily Workflow Tracker'!RC[10],"""")"
     Range("E6").FormulaR1C1 = "=IF(RC[-4]<>"""",'Daily Workflow Tracker'!RC[16],"""")"
     Range("F6").FormulaR1C1 = "=IF(RC[-5]<>"""",'Daily Workflow Tracker'!RC[17],"""")"
     
         
     Range("A6:F6").Copy
     Range("A7:A65536").Select
     Selection.PasteSpecial Paste:=xlPasteFormulas, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
     Range("A6:F65536").Select
     Selection.Copy
     Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False

     Range("A6:F65536").Select
     Selection.Copy
     Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
     Application.CutCopyMode = False

     Range("A6:F65536").Select
     ActiveSheet.Range("$A6:$F65536").AutoFilter Field:=1, Criteria1:="="
     Selection.SpecialCells(xlCellTypeVisible).Select
     Selection.EntireRow.Delete
     ActiveSheet.ShowAllData

     Range("F65536").End(xlUp).Select
     Range(Selection, "A6").Select

          Selection.Borders(xlDiagonalDown).LineStyle = xlNone
          Selection.Borders(xlDiagonalUp).LineStyle = xlNone
          Selection.Borders(xlEdgeLeft).LineStyle = xlNone
          Selection.Borders(xlEdgeTop).LineStyle = xlNone
          Selection.Borders(xlEdgeBottom).LineStyle = xlNone
          Selection.Borders(xlEdgeRight).LineStyle = xlNone
          Selection.Borders(xlInsideVertical).LineStyle = xlNone
          Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
          Selection.Borders(xlDiagonalDown).LineStyle = xlNone
          Selection.Borders(xlDiagonalUp).LineStyle = xlNone

          With Selection.Borders(xlInsideVertical)
              .LineStyle = xlContinuous
              .ColorIndex = 0
              .TintAndShade = 0
              .Weight = xlThin
          End With
          With Selection.Borders(xlInsideHorizontal)
              .LineStyle = xlContinuous
              .ColorIndex = 0
              .TintAndShade = 0
              .Weight = xlThin
          End With


          With Selection.Borders(xlEdgeLeft)
              .LineStyle = xlContinuous
              .ColorIndex = 0
              .TintAndShade = 0
              .Weight = xlMedium
          End With
          With Selection.Borders(xlEdgeTop)
              .LineStyle = xlContinuous
              .ColorIndex = 0
              .TintAndShade = 0
              .Weight = xlMedium
          End With
          With Selection.Borders(xlEdgeBottom)
              .LineStyle = xlContinuous
              .ColorIndex = 0
              .TintAndShade = 0
              .Weight = xlMedium
          End With
          With Selection.Borders(xlEdgeRight)
              .LineStyle = xlContinuous
              .ColorIndex = 0
              .TintAndShade = 0
              .Weight = xlMedium
          End With


     Range("G5").Value = TempVal
     Application.ScreenUpdating = True
     Application.DisplayAlerts = True

     Range("A5").Select

End Sub






Please help

Thanks
Vishal
 
#1
    ebgreen

    • Total Posts : 8227
    • Scores: 98
    • Reward points : 0
    • Joined: 7/12/2005
    • Status: offline
    Re:need a vbscript for multiple excel files Thursday, July 08, 2010 1:16 AM (permalink)
    0
    What you have written is VBA not VBScript. Regardless I would first try recording a macro of opening the other file. That should get you going in the right direction.
    "... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
    Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
    http://www.visualbasicscript.com/m_47117/tm.htm
     
    #2
      vishalvijayan

      • Total Posts : 6
      • Scores: 0
      • Reward points : 0
      • Joined: 7/5/2010
      • Status: offline
      Re:need a vbscript for multiple excel files Monday, July 12, 2010 4:58 PM (permalink)
      0
      Thanks ebgreen.

      Can you help me with the codes. 
       
      #3
        ebgreen

        • Total Posts : 8227
        • Scores: 98
        • Reward points : 0
        • Joined: 7/12/2005
        • Status: offline
        Re:need a vbscript for multiple excel files Tuesday, July 13, 2010 1:30 AM (permalink)
        0
        Did you do what I suggested?
        "... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
        Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
        http://www.visualbasicscript.com/m_47117/tm.htm
         
        #4
          vishalvijayan

          • Total Posts : 6
          • Scores: 0
          • Reward points : 0
          • Joined: 7/5/2010
          • Status: offline
          Re:need a vbscript for multiple excel files Tuesday, July 20, 2010 5:12 PM (permalink)
          0
          yes...
          I have recorded a macro for the opening the other file.

          Sub Macro1()
          '
          ' Macro1 Macro
          ' Open a existing file (book1.xls)
          '
              Workbooks.Open Filename:="C:\Users\vishalv\Desktop\VBA\Book1.xlsx"
          End Sub


          now whats next..... please guide. Also advise any good book on VBA programming in Excel .
          Thank you

           
          #5
            ebgreen

            • Total Posts : 8227
            • Scores: 98
            • Reward points : 0
            • Joined: 7/12/2005
            • Status: offline
            Re:need a vbscript for multiple excel files Wednesday, July 21, 2010 1:37 AM (permalink)
            0
            Now you would take the code that you already have and adopt it to use the sheet that you opened.
            "... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
            Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
            http://www.visualbasicscript.com/m_47117/tm.htm
             
            #6

              Online Bookmarks Sharing: Share/Bookmark

              Jump to:

              Current active users

              There are 0 members and 1 guests.

              Icon Legend and Permission

              • New Messages
              • No New Messages
              • Hot Topic w/ New Messages
              • Hot Topic w/o New Messages
              • Locked w/ New Messages
              • Locked w/o New Messages
              • Read Message
              • Post New Thread
              • Reply to message
              • Post New Poll
              • Submit Vote
              • Post reward post
              • Delete my own posts
              • Delete my own threads
              • Rate post

              2000-2012 ASPPlayground.NET Forum Version 3.9