Hey guys, I have this macro which draws data from each sheet in my workbook.
Dim i As Integer
Dim wsname As String
For i = 2 To ThisWorkbook.Sheets.Count
Sheets(i).Select
wsname = Sheets(i).Name
Range("D1010:F1010,H1010").Copy
Sheets(1).Select
Range("C5").Select
If ActiveCell.Value <> "" Then
If ActiveCell.Offset(1, 0).Value <> "" Then
ActiveCell.End(xlDown).Select
ActiveCell.Offset(1, 0).Select
ActiveSheet.Paste
Else
ActiveCell.Offset(1, 0).Select
ActiveSheet.Paste
End If
Else
ActiveSheet.Paste
End If
ActiveCell.Offset(0, -1).Value = wsname
Next i
Range("B5:F153").Select
With Selection.Font
.Name = "Arial"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
The one problem I am having is some of the pages won't have figures in the cells and will be putting a #div/0 error. Basically what I want to achieve is either hide the #div/0 errors using my autofilter or work out how to not copy the data if there is an error.
Thanks for any help
Dim i As Integer
Dim wsname As String
For i = 2 To ThisWorkbook.Sheets.Count
Sheets(i).Select
wsname = Sheets(i).Name
Range("D1010:F1010,H1010").Copy
Sheets(1).Select
Range("C5").Select
If ActiveCell.Value <> "" Then
If ActiveCell.Offset(1, 0).Value <> "" Then
ActiveCell.End(xlDown).Select
ActiveCell.Offset(1, 0).Select
ActiveSheet.Paste
Else
ActiveCell.Offset(1, 0).Select
ActiveSheet.Paste
End If
Else
ActiveSheet.Paste
End If
ActiveCell.Offset(0, -1).Value = wsname
Next i
Range("B5:F153").Select
With Selection.Font
.Name = "Arial"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
The one problem I am having is some of the pages won't have figures in the cells and will be putting a #div/0 error. Basically what I want to achieve is either hide the #div/0 errors using my autofilter or work out how to not copy the data if there is an error.
Thanks for any help