Results 1 to 8 of 8

What Wrong With my Code? compile information to worksheet

Threaded View

  1. #1
    Registered User
    Join Date
    08-21-2013
    Location
    United States
    MS-Off Ver
    2010
    Posts
    41

    What Wrong With my Code? compile information to worksheet

    I've written the attached code and can't figure out what i'm doing wrong. I'm trying to copy, sort, and paste information from a bunch of sheets. The below code goes into a death spiral copying and pasting only from the first sheet in my workbook. What's wrong with my code? Why won't it continue through the loop?

    Sub Compile()
    
    
        Dim sh As Worksheet
        Dim UKsh As Worksheet
        Dim EUsh As Worksheet
        Dim USsh As Worksheet
        Dim EUrow As Long, UKrow As Long, USrow As Long
        Dim x As Long, y As Long
    
        EUrow = 2
        UKrow = 2
        USrow = 2
    
    Set UKsh = Sheets("UK")
    Set EUsh = Sheets("EU")
    Set USsh = Sheets("US")
    
    
    For Each sh In Worksheets
    
            If Range("a60") = "EU" Then
                ActiveSheet.Range("C8:C48").Copy
                EUsh.Range("A" & EUrow).PasteSpecial Transpose:=True
                Application.CutCopyMode = False
                EUrow = EUrow + 1
            ElseIf Range("a60") = "UK" Then
                ActiveSheet.Range("C8:C48").Copy
                UKsh.Range("A" & UKrow).PasteSpecial Transpose:=True
                Application.CutCopyMode = False
                UKrow = UKrow + 1
            Else
                ActiveSheet.Range("C8:C48").Copy
                USsh.Range("A" & USrow).PasteSpecial Transpose:=True
                Application.CutCopyMode = False
                USrow = USrow + 1
            End If
        
    
    Next
    End Sub
    Last edited by sjennings007; 12-23-2015 at 06:55 PM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] How to handle error code when wrong password is entered for unprotect worksheet?
    By redsab in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-18-2020, 09:01 AM
  2. [SOLVED] VBA code needed that will compile data onto another worksheet
    By Jim885 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 05-11-2014, 08:27 PM
  3. Problem with VBA code to show a veryhidden worksheet - Compile Error
    By maryren in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-06-2014, 10:42 AM
  4. [SOLVED] Excel VBA Compile Error wrong number of arguments
    By gjwilson1216 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-24-2013, 03:08 PM
  5. [SOLVED] What is wrong with this code? Compile error etc
    By ExcelFailure in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 08-30-2013, 08:18 AM
  6. [SOLVED] VBA - Compile Error - Wrong number of arguments
    By Janto724 in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 06-28-2013, 06:04 AM
  7. Compile Error - Wrong number of arguments
    By freebird_wr in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-25-2013, 09:34 AM

Tags for this Thread

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