Results 1 to 2 of 2

Copying an activecell range and pasting to another activecell range

Threaded View

  1. #1
    Registered User
    Join Date
    10-01-2014
    Location
    london, england
    MS-Off Ver
    office 13
    Posts
    18

    Copying an activecell range and pasting to another activecell range

    Hi All,

    Thanks for looking - when i execute the following macro automatically the following section of the macro does not copy the contents to the destination cells - however it does work if i execute it from the VB Editor?

    ActiveCell.Offset(-1, -3).Resize(, 3).Copy
            ActiveCell.Offset(, -3).PasteSpecial Paste:=xlPasteAll
            ActiveCell.Offset(-1, 8).Resize(, 3).Copy
            ActiveCell.Offset(, 8).PasteSpecial Paste:=xlPasteAll
    
    Here's the macro in full;
    
    Dim Stress As Workbook
    Dim wsPivot As Worksheet
    Dim wsAnalysis As Worksheet
    
    
    Set Stress = Workbooks("stress.xlsx")
    Set wsPivot = Stress.Worksheets("Pivot")
    Set wsAnalysis = Stress.Worksheets("Analysis")
    
    Finalrow = wsAnalysis.Cells(Rows.Count, 1).End(xlUp).Row
    Targetrow = Finalrow + 1
    
    
    
    
     With Stress
        
            wsPivot.Range("f23:j23").Copy
        
        wsAnalysis.Range("AM" & Targetrow).PasteSpecial xlPasteValues
        ActiveCell.Offset(-1, -3).Resize(, 3).Copy
        ActiveCell.Offset(, -3).PasteSpecial Paste:=xlPasteAll
        ActiveCell.Offset(-1, 8).Resize(, 3).Copy
        ActiveCell.Offset(, 8).PasteSpecial Paste:=xlPasteAll
        
        With ActiveCell.Offset(, -1)
            .HorizontalAlignment = xlLeft
            .NumberFormat = "mmm (yy)"
    
        End With
    
    
        wsPivot.Range("f24:j24").Copy
        
        wsAnalysis.Range("BE" & Targetrow).PasteSpecial xlPasteValues
        ActiveCell.Offset(-1, -1).Copy
        ActiveCell.Offset(, -1).PasteSpecial Paste:=xlPasteAll
        
        With ActiveCell.Offset(, 5)
            .HorizontalAlignment = xlLeft
            .NumberFormat = "mmm (yy)"
    
        End With
    
    
        wsPivot.Range("f25:j25").Copy
        
        wsAnalysis.Range("BS" & Targetrow).PasteSpecial xlPasteValues
        ActiveCell.Offset(-1, -3).Resize(, 3).Copy
        ActiveCell.Offset(, -3).PasteSpecial Paste:=xlPasteAll
        ActiveCell.Offset(-1, 8).Resize(, 3).Copy
        ActiveCell.Offset(, 8).PasteSpecial Paste:=xlPasteAll
        
        With ActiveCell.Offset(, -1)
            .HorizontalAlignment = xlLeft
            
        End With
    
    End With 
    
    End Sub
    Also some suggestions on how to turn the code into a loop would be great as well, I'm fairly new to ranges and referencing them. If you have any suggested reading as well, I've got vba and macros for microsoft office by jelen but further reading would be helpful?

    Many thanks in advance,

    LB
    Last edited by Fotis1991; 11-12-2014 at 08:09 AM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Use ActiveCell as Range
    By 55horses in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-10-2012, 12:13 AM
  2. Output contents of Activecell when Activecell may be string or numeric.
    By jfriddle in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-09-2012, 12:27 PM
  3. Range of the ActiveCell
    By escelinen in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-13-2007, 08:14 AM
  4. ActiveCell.Row in Range().Select?
    By thebluerider in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-19-2006, 06:45 AM
  5. [SOLVED] Name of range containing ActiveCell?
    By Ed in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 01-03-2005, 09:06 PM

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