+ Reply to Thread
Results 1 to 2 of 2

Create a volume tracking table with VBA

Hybrid View

Ranmandaman Create a volume tracking... 07-04-2013, 12:19 PM
Ranmandaman Re: Create a volume tracking... 07-05-2013, 04:40 PM
  1. #1
    Registered User
    Join Date
    06-11-2013
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    15

    Create a volume tracking table with VBA

    Hi All

    I'm trying I create something in VBA but I don't know whether I could simplify this code any further. Just to explain what this code does is update a volume tracking table on each sheet in the workbook. So for Sheet Q4 it'll go through Sheets Q1-Q3 and copy the data across to Q4.

    Is there any way to simplify this with a loop - I tried but keep getting stuck because the amount I copy for Q4 is different to what I'd copy for Q1 for examples

    Anyway the code is here

    
    Dim wks As Worksheet 
    
    With Workbooks(cFileName) 
    On Error Resume Next 
    
    For Each wks In .Worksheets 
    Select Case wks.Name 
        Case "Q2" 
            .Sheets("Q2").Cells(9, 11) = .Sheets("Q1").Cells(9, 11) 
            .Sheets("Q2").Cells(11, 11) = .Sheets("Q1").Cells(11, 11) 
            .Sheets("Q2").Cells(13, 11) = .Sheets("Q1").Cells(13, 11) 
            .Sheets("Q2").Cells(43, 6) = .Sheets("Q1").Cells(43, 6) 
            .Sheets("Q2").Cells(43, 8) = .Sheets("Q1").Cells(43, 8) 
        Case "Q3" 
            .Sheets("Q3").Cells(9, 11) = .Sheets("Q1").Cells(9, 11) 
            .Sheets("Q3").Cells(11, 11) = .Sheets("Q1").Cells(11, 11) 
            .Sheets("Q3").Cells(13, 11) = .Sheets("Q1").Cells(13, 11) 
            .Sheets("Q3").Cells(9, 12) = .Sheets("Q2").Cells(9, 12) 
            .Sheets("Q3").Cells(11, 12) = .Sheets("Q2").Cells(11, 12) 
            .Sheets("Q3").Cells(13, 12) = .Sheets("Q2").Cells(13, 12) 
            .Sheets("Q2").Cells(43, 6) = .Sheets("Q1").Cells(43, 6) 
            .Sheets("Q2").Cells(43, 8) = .Sheets("Q1").Cells(43, 8) 
            .Sheets("Q2").Cells(44, 6) = .Sheets("Q1").Cells(44, 6) 
            .Sheets("Q2").Cells(44, 8) = .Sheets("Q1").Cells(44, 8) 
        Case "Q4" 
            .Sheets("Q4").Cells(9, 11) = .Sheets("Q1").Cells(9, 11) 
            .Sheets("Q4").Cells(11, 11) = .Sheets("Q1").Cells(11, 11) 
            .Sheets("Q4").Cells(13, 11) = .Sheets("Q1").Cells(13, 11) 
            .Sheets("Q4").Cells(9, 12) = .Sheets("Q2").Cells(9, 12) 
            .Sheets("Q4").Cells(11, 12) = .Sheets("Q2").Cells(11, 12) 
            .Sheets("Q4").Cells(13, 12) = .Sheets("Q2").Cells(13, 12) 
            .Sheets("Q4").Cells(9, 13) = .Sheets("Q3").Cells(9, 13) 
            .Sheets("Q4").Cells(11, 13) = .Sheets("Q3").Cells(11, 13) 
            .Sheets("Q4").Cells(13, 13) = .Sheets("Q3").Cells(13, 13) 
            .Sheets("Q2").Cells(43, 6) = .Sheets("Q1").Cells(43, 6) 
            .Sheets("Q2").Cells(43, 8) = .Sheets("Q1").Cells(43, 8) 
            .Sheets("Q2").Cells(44, 6) = .Sheets("Q1").Cells(44, 6) 
            .Sheets("Q2").Cells(44, 8) = .Sheets("Q1").Cells(44, 8) 
            .Sheets("Q2").Cells(45, 6) = .Sheets("Q1").Cells(45, 6) 
            .Sheets("Q2").Cells(45, 8) = .Sheets("Q1").Cells(45, 8) 
    End Select 
    Next wks 
    
    End With

  2. #2
    Registered User
    Join Date
    06-11-2013
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    15

    Re: Create a volume tracking table with VBA

    Any help guys?

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1