<table border="0" cellpadding="0" cellspacing="0" width="1493"><col style="width: 140pt;" width="186"><col style="width: 179pt;" width="239"><col style="width: 45pt;" width="60"><col style="width: 63pt;" span="7" width="84"><col style="width: 63pt;" span="2" width="84"><col style="width: 63pt;" span="3" width="84"><tbody><tr style="height: 12.75pt;" height="17"><td class="xl63" style="height: 12.75pt; width: 140pt;" height="17" width="186">Hi, I need help trying to decode this macro:
I have several sheets similar to the one below. Each sheet has 66rowsx15 columns. 19 Sheets.</td><td class="xl63" style="width: 179pt;" width="239"></td><td class="xl63" style="width: 45pt;" width="60"></td><td class="xl67" style="width: 63pt;" width="84"></td><td class="xl67" style="width: 63pt;" width="84"></td><td class="xl67" style="width: 63pt;" width="84"></td><td class="xl67" style="width: 63pt;" width="84"></td><td class="xl67" style="width: 63pt;" width="84"></td><td class="xl67" style="width: 63pt;" width="84"></td><td class="xl67" style="width: 63pt;" width="84"></td><td class="xl67" style="width: 63pt;" width="84"></td><td class="xl67" style="width: 63pt;" width="84"></td><td class="xl67" style="width: 63pt;" width="84"></td><td class="xl67" style="width: 63pt;" width="84"></td><td class="xl67" style="width: 63pt;" width="84"></td></tr><tr style="height: 12.75pt;" height="17"><td class="xl63" style="height: 12.75pt;" height="17"></td><td class="xl64"></td><td class="xl63"></td><td class="xl65"></td><td class="xl65"></td><td class="xl65"></td><td class="xl65"></td><td class="xl65"></td><td class="xl65"></td><td class="xl65"></td><td class="xl65"></td><td class="xl65"></td><td class="xl65"></td><td class="xl65"></td><td class="xl65">
Excel 2007
I have this macro:
Sub movedata()
Dim LR As Long, LR2 As Long, LC As Long, Ctr As Long, NR As Long, ToMove As Long, RptLR As Long
On Error Resume Next
Sheets("Report").Select
If Err Then Worksheets.Add.Name = "Report"
On Error GoTo 0
With Sheets("Report")
Dim wks As Worksheet
Application.ScreenUpdating = False
Sheets(1).Select
On Error Resume Next
Sheets("Report").Select
If Err Then Worksheets.Add.Name = "Report"
On Error GoTo 0
End With
With Sheets("Report")
.Range("A1").Resize(, 5).Value = [{"Cat07","Cat08","CC02","Month","Amount"}]
RptLR = .Cells(Rows.Count, 1).End(xlUp).Row
If RptLR > 1 Then
.Range("A2:Z" & RptLR).ClearContents
End If
End With
For Each wks In ThisWorkbook.Worksheets
If wks.Name<> "Instructions" And wks.Name<> "Report" Then
With wks
.Select
LC = .Cells.Find(What:="*", SearchDirection:=xlPrevious, SearchOrder:=xlByColumns).Column
LR = .Cells(Rows.Count, 1).End(xlUp).Row
.Cells(1, LC + 2).Resize(, 5).Value = [{"Cat08","Cat09","CC02","Month","Amount"}]
ToMove = LC - 1
For Ctr = 2 To LR Step 1
NR = .Cells(Rows.Count, LC + 2).End(xlUp).Row
.Range("A" & Ctr).Copy .Range(Cells(NR + 1, LC + 2), Cells(NR + ToMove - 2, LC + 2))
.Range("B" & Ctr).Copy .Range(Cells(NR + 1, LC + 3), Cells(NR + ToMove - 2, LC + 3))
.Range("C" & Ctr).Copy .Range(Cells(NR + 1, LC + 4), Cells(NR + ToMove - 2, LC + 4))
.Range(Cells(1, 4), Cells(1, LC)).Copy
With .Cells(NR + 1, LC + 5)
.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:=False, Transpose:=True
End With
.Range(Cells(Ctr, 4), Cells(Ctr, LC)).Copy
With .Cells(NR + 1, LC + 6)
.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:=False, Transpose:=True
End With
Next Ctr
LR2 = .Cells(Rows.Count, LC + 2).End(xlUp).Row
RptLR = Sheets("Report").Cells(Rows.Count, 1).End(xlUp).Row
.Range(Cells(2, LC + 2), Cells(LR2, LC + 10)).Copy Sheets("Report").Range("A" & RptLR + 1)
.Range(Cells(1, LC + 2), Cells(LR2, LC + 100)).ClearContents
.Range("A1").Select
Application.CutCopyMode = False
End With
End If
Next wks
Sheets("Report").Select
RptLR = Cells(Rows.Count, 1).End(xlUp).Row
Range("A1:Z" & RptLR).Columns.AutoFit
Range("I1").Select
Application.ScreenUpdating = True
End Sub
The file is linked to a separate file within the same folder. Everytime I run the macro it opens up a window to open a file..each time i have to press cancel..and when I press cancel, it pops up again.
Can someone help?
Thanks in advance!!
tygrl510
I have several sheets similar to the one below. Each sheet has 66rowsx15 columns. 19 Sheets.</td><td class="xl63" style="width: 179pt;" width="239"></td><td class="xl63" style="width: 45pt;" width="60"></td><td class="xl67" style="width: 63pt;" width="84"></td><td class="xl67" style="width: 63pt;" width="84"></td><td class="xl67" style="width: 63pt;" width="84"></td><td class="xl67" style="width: 63pt;" width="84"></td><td class="xl67" style="width: 63pt;" width="84"></td><td class="xl67" style="width: 63pt;" width="84"></td><td class="xl67" style="width: 63pt;" width="84"></td><td class="xl67" style="width: 63pt;" width="84"></td><td class="xl67" style="width: 63pt;" width="84"></td><td class="xl67" style="width: 63pt;" width="84"></td><td class="xl67" style="width: 63pt;" width="84"></td><td class="xl67" style="width: 63pt;" width="84"></td></tr><tr style="height: 12.75pt;" height="17"><td class="xl63" style="height: 12.75pt;" height="17"></td><td class="xl64"></td><td class="xl63"></td><td class="xl65"></td><td class="xl65"></td><td class="xl65"></td><td class="xl65"></td><td class="xl65"></td><td class="xl65"></td><td class="xl65"></td><td class="xl65"></td><td class="xl65"></td><td class="xl65"></td><td class="xl65"></td><td class="xl65">
Excel Workbook | ||||||||
---|---|---|---|---|---|---|---|---|
A | B | C | D | E | F | |||
1 | CATEGORY08 | CATEGORY09 | CC03 | Apr | May | Jun | ||
2 | 040_Share Based Compensation | 0400_Option Expense | SLSMGMT | 26 | 26 | 26 | ||
SLSMGMT |
Cell Formulas | ||
---|---|---|
Range | Formula | |
D2 | ='T:\Finance\RTY\FY12 Budget\[FY12 BESA_BIF BUDGET (SUB3).xlsx]SLSMGMT'!I$12 | |
E2 | ='T:\Finance\RTY\FY12 Budget\[FY12 BESA_BIF BUDGET (SUB3).xlsx]SLSMGMT'!J$12 | |
F2 | ='T:\Finance\RTY\FY12 Budget\[FY12 BESA_BIF BUDGET (SUB3).xlsx]SLSMGMT'!K$12 |
I have this macro:
Sub movedata()
Dim LR As Long, LR2 As Long, LC As Long, Ctr As Long, NR As Long, ToMove As Long, RptLR As Long
On Error Resume Next
Sheets("Report").Select
If Err Then Worksheets.Add.Name = "Report"
On Error GoTo 0
With Sheets("Report")
Dim wks As Worksheet
Application.ScreenUpdating = False
Sheets(1).Select
On Error Resume Next
Sheets("Report").Select
If Err Then Worksheets.Add.Name = "Report"
On Error GoTo 0
End With
With Sheets("Report")
.Range("A1").Resize(, 5).Value = [{"Cat07","Cat08","CC02","Month","Amount"}]
RptLR = .Cells(Rows.Count, 1).End(xlUp).Row
If RptLR > 1 Then
.Range("A2:Z" & RptLR).ClearContents
End If
End With
For Each wks In ThisWorkbook.Worksheets
If wks.Name<> "Instructions" And wks.Name<> "Report" Then
With wks
.Select
LC = .Cells.Find(What:="*", SearchDirection:=xlPrevious, SearchOrder:=xlByColumns).Column
LR = .Cells(Rows.Count, 1).End(xlUp).Row
.Cells(1, LC + 2).Resize(, 5).Value = [{"Cat08","Cat09","CC02","Month","Amount"}]
ToMove = LC - 1
For Ctr = 2 To LR Step 1
NR = .Cells(Rows.Count, LC + 2).End(xlUp).Row
.Range("A" & Ctr).Copy .Range(Cells(NR + 1, LC + 2), Cells(NR + ToMove - 2, LC + 2))
.Range("B" & Ctr).Copy .Range(Cells(NR + 1, LC + 3), Cells(NR + ToMove - 2, LC + 3))
.Range("C" & Ctr).Copy .Range(Cells(NR + 1, LC + 4), Cells(NR + ToMove - 2, LC + 4))
.Range(Cells(1, 4), Cells(1, LC)).Copy
With .Cells(NR + 1, LC + 5)
.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:=False, Transpose:=True
End With
.Range(Cells(Ctr, 4), Cells(Ctr, LC)).Copy
With .Cells(NR + 1, LC + 6)
.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:=False, Transpose:=True
End With
Next Ctr
LR2 = .Cells(Rows.Count, LC + 2).End(xlUp).Row
RptLR = Sheets("Report").Cells(Rows.Count, 1).End(xlUp).Row
.Range(Cells(2, LC + 2), Cells(LR2, LC + 10)).Copy Sheets("Report").Range("A" & RptLR + 1)
.Range(Cells(1, LC + 2), Cells(LR2, LC + 100)).ClearContents
.Range("A1").Select
Application.CutCopyMode = False
End With
End If
Next wks
Sheets("Report").Select
RptLR = Cells(Rows.Count, 1).End(xlUp).Row
Range("A1:Z" & RptLR).Columns.AutoFit
Range("I1").Select
Application.ScreenUpdating = True
End Sub
The file is linked to a separate file within the same folder. Everytime I run the macro it opens up a window to open a file..each time i have to press cancel..and when I press cancel, it pops up again.
Can someone help?
Thanks in advance!!
tygrl510