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
Bookmarks