Hi gsjan1
I've inserted into your code the code to do this
How can I write this macro so that each week it will copy this information into the next available column
I also took the liberty to rewrite the first several lines of your code. The code was obviously recorded which is absolutely fine. Recorded code, however, results in many unnecessary lines that can be edited out. You'll notice in the lines I rewrote, there's no selecting going on.
Try the code then try to rewrite the rest of it without selecting...just be sure to notice the . (dot) within the With...End With statements. This is critical to the success of the code. If you need further help, let me know.
Option Explicit
Sub Trend()
Dim LC As Long
Dim NC As Long
' Keyboard Shortcut: Ctrl+t
Application.ScreenUpdating = False 'turn off screen flicker
With Sheets("AMB")
.Range("B5").Copy
End With
With Sheets("Trend")
LC = .Range("XFD5").End(xlToLeft).Column
If LC = 1 Then
NC = LC + 1
Else
NC = LC + 1
End If
.Cells(5, NC).PasteSpecial Paste:=xlPasteAll
End With
With Sheets("AMB")
.Range("N11:N16").Copy
End With
With Sheets("Trend")
.Cells(6, NC).PasteSpecial Paste:=xlPasteAll
End With
Sheets("AMB").Select
Range("I24").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Trend").Select
' Range("B12").Select
Cells(12, NC).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("AMB").Select
ActiveWindow.SmallScroll Down:=18
Range("I32:I33").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Trend").Select
Cells(13, NC).Select
' Range("B13:B14").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("AMB").Select
Range("K41:K42").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Trend").Select
Cells(15, NC).Select
' Range("B15:B16").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("AMB").Select
Range("F49:F50").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Trend").Select
Cells(17, NC).Select
' Range("B17:B18").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("B5").Select
Application.CutCopyMode = False
Selection.NumberFormat = "m/d;@"
Range("B6:B18").Select
Selection.NumberFormat = "0.0%"
Application.ScreenUpdating = True
End Sub
Bookmarks