#6
by sweetken » Fri Aug 19, 2016 10:28 am
Code: Select all
Sub Glass()
Application.ScreenUpdating = False
Dim last As Integer
Dim i As Integer
Dim ir As Long
Sheets(1).Select
Range("B5").Select
Selection.Copy
Sheets.Add After:=Sheets(Sheets.Count)
ActiveSheet.Name = "Glass"
'Sheets("Glass").Select
[a1] = "Panel"
[a300].End(xlUp).Offset(1, 0).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Sheets(1).Select
Range("o16").Select
Selection.End(xlUp).Select
last = ActiveCell.Row
Range("O7:U" & last).Select
'Range("J7:M" & a).Select
Selection.Copy
'Sheets.Add After:=Sheets(Sheets.Count)
Sheets("Glass").Select
Range("B1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
ir = Range("a" & Rows.Count).End(xlUp).Row
For i = 1 To ir Step 1
If Range("a" & i) <> "" Then
[a300].End(xlUp).Copy
[a300].End(xlUp).Offset(1, 0).Select
ActiveSheet.Paste
End If
Next i
ir = Range("a" & Rows.Count).End(xlUp).Row
For i = 1 To ir Step 1
If Range("b" & i) <> "" Then
[a300].End(xlUp).Copy
[a300].End(xlUp).Offset(1, 0).Select
ActiveSheet.Paste
End If
Next i
ir = Range("a" & Rows.Count).End(xlUp).Row
For i = 1 To ir Step 1
If Range("b" & i) = "" Then
'[a300].End(xlUp).Copy
[a300].End(xlUp).Delete
End If
Next i
'sheet2
Sheets(2).Select
Range("B5").Select
Selection.Copy
Sheets("Glass").Select
[a300].End(xlUp).Offset(1, 0).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Sheets(2).Select
Range("o16").Select
Selection.End(xlUp).Select
last = ActiveCell.Row
Range("O8:U" & last).Select
'Range("J7:M" & a).Select
Selection.Copy
'Sheets.Add After:=Sheets(Sheets.Count)
Sheets("Glass").Select
Range("B" & last).Select
[b100].End(xlUp).Offset(1, 0).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
ir = Range("a" & Rows.Count).End(xlUp).Row
For i = 1 To ir Step 1
If Range("a" & i) <> "" Then
[a300].End(xlUp).Copy
[a300].End(xlUp).Offset(1, 0).Select
ActiveSheet.Paste
End If
Next i
ir = Range("a" & Rows.Count).End(xlUp).Row
For i = 1 To ir Step 1
If Range("b" & i) <> "" Then
[a300].End(xlUp).Copy
[a300].End(xlUp).Offset(1, 0).Select
ActiveSheet.Paste
End If
Next i
ir = Range("a" & Rows.Count).End(xlUp).Row
For i = 1 To ir Step 1
If Range("b" & i) = "" Then
'[a300].End(xlUp).Copy
[a300].End(xlUp).Delete
End If
Next i
'sheet3
Sheets(3).Select
Range("B5").Select
Selection.Copy
Sheets("Glass").Select
[a300].End(xlUp).Offset(1, 0).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Sheets(3).Select
Range("o16").Select
Selection.End(xlUp).Select
last = ActiveCell.Row
Range("O8:U" & last).Select
'Range("J7:M" & a).Select
Selection.Copy
'Sheets.Add After:=Sheets(Sheets.Count)
Sheets("Glass").Select
Range("B" & last).Select
[b100].End(xlUp).Offset(1, 0).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
ir = Range("a" & Rows.Count).End(xlUp).Row
For i = 1 To ir Step 1
If Range("a" & i) <> "" Then
[a300].End(xlUp).Copy
[a300].End(xlUp).Offset(1, 0).Select
ActiveSheet.Paste
End If
Next i
ir = Range("a" & Rows.Count).End(xlUp).Row
For i = 1 To ir Step 1
If Range("b" & i) <> "" Then
[a300].End(xlUp).Copy
[a300].End(xlUp).Offset(1, 0).Select
ActiveSheet.Paste
End If
Next i
ir = Range("a" & Rows.Count).End(xlUp).Row
For i = 1 To ir Step 1
If Range("b" & i) = "" Then
'[a300].End(xlUp).Copy
[a300].End(xlUp).Delete
End If
Next i
[i5].Select
'sheet4
Sheets(4).Select
Range("B5").Select
Selection.Copy
Sheets("Glass").Select
[a300].End(xlUp).Offset(1, 0).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Sheets(4).Select
Range("o16").Select
Selection.End(xlUp).Select
last = ActiveCell.Row
Range("O8:U" & last).Select
'Range("J7:M" & a).Select
Selection.Copy
'Sheets.Add After:=Sheets(Sheets.Count)
Sheets("Glass").Select
Range("B" & last).Select
[b100].End(xlUp).Offset(1, 0).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
ir = Range("a" & Rows.Count).End(xlUp).Row
For i = 1 To ir Step 1
If Range("a" & i) <> "" Then
[a300].End(xlUp).Copy
[a300].End(xlUp).Offset(1, 0).Select
ActiveSheet.Paste
End If
Next i
ir = Range("a" & Rows.Count).End(xlUp).Row
For i = 1 To ir Step 1
If Range("b" & i) <> "" Then
[a300].End(xlUp).Copy
[a300].End(xlUp).Offset(1, 0).Select
ActiveSheet.Paste
End If
Next i
ir = Range("a" & Rows.Count).End(xlUp).Row
For i = 1 To ir Step 1
If Range("b" & i) = "" Then
'[a300].End(xlUp).Copy
[a300].End(xlUp).Delete
End If
Next i
'sheet5
Sheets(5).Select
Range("B5").Select
Selection.Copy
Sheets("Glass").Select
[a300].End(xlUp).Offset(1, 0).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Sheets(5).Select
Range("o16").Select
Selection.End(xlUp).Select
last = ActiveCell.Row
Range("O8:U" & last).Select
'Range("J7:M" & a).Select
Selection.Copy
'Sheets.Add After:=Sheets(Sheets.Count)
Sheets("Glass").Select
Range("B" & last).Select
[b100].End(xlUp).Offset(1, 0).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
ir = Range("a" & Rows.Count).End(xlUp).Row
For i = 1 To ir Step 1
If Range("a" & i) <> "" Then
[a300].End(xlUp).Copy
[a300].End(xlUp).Offset(1, 0).Select
ActiveSheet.Paste
End If
Next i
ir = Range("a" & Rows.Count).End(xlUp).Row
For i = 1 To ir Step 1
If Range("b" & i) <> "" Then
[a300].End(xlUp).Copy
[a300].End(xlUp).Offset(1, 0).Select
ActiveSheet.Paste
End If
Next i
ir = Range("a" & Rows.Count).End(xlUp).Row
For i = 1 To ir Step 1
If Range("b" & i) = "" Then
'[a300].End(xlUp).Copy
[a300].End(xlUp).Delete
End If
Next i
'sheet6
Sheets(6).Select
Range("B5").Select
Selection.Copy
Sheets("Glass").Select
[a300].End(xlUp).Offset(1, 0).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Sheets(6).Select
Range("o16").Select
Selection.End(xlUp).Select
last = ActiveCell.Row
Range("O8:U" & last).Select
Selection.Copy
Sheets("Glass").Select
Range("B" & last).Select
[b100].End(xlUp).Offset(1, 0).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
ir = Range("a" & Rows.Count).End(xlUp).Row
For i = 1 To ir Step 1
If Range("a" & i) <> "" Then
[a300].End(xlUp).Copy
[a300].End(xlUp).Offset(1, 0).Select
ActiveSheet.Paste
End If
Next i
ir = Range("a" & Rows.Count).End(xlUp).Row
For i = 1 To ir Step 1
If Range("b" & i) <> "" Then
[a300].End(xlUp).Copy
[a300].End(xlUp).Offset(1, 0).Select
ActiveSheet.Paste
End If
Next i
ir = Range("a" & Rows.Count).End(xlUp).Row
For i = 1 To ir Step 1
If Range("b" & i) = "" Then
'[a300].End(xlUp).Copy
[a300].End(xlUp).Delete
End If
Next i
'Sheet7
Sheets(7).Select
Range("B5").Select
Selection.Copy
Sheets("Glass").Select
[a300].End(xlUp).Offset(1, 0).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Sheets(7).Select
Range("o16").Select
Selection.End(xlUp).Select
last = ActiveCell.Row
Range("O8:U" & last).Select
Selection.Copy
Sheets("Glass").Select
Range("B" & last).Select
[b100].End(xlUp).Offset(1, 0).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
ir = Range("a" & Rows.Count).End(xlUp).Row
For i = 1 To ir Step 1
If Range("a" & i) <> "" Then
[a300].End(xlUp).Copy
[a300].End(xlUp).Offset(1, 0).Select
ActiveSheet.Paste
End If
Next i
ir = Range("a" & Rows.Count).End(xlUp).Row
For i = 1 To ir Step 1
If Range("b" & i) <> "" Then
[a300].End(xlUp).Copy
[a300].End(xlUp).Offset(1, 0).Select
ActiveSheet.Paste
End If
Next i
ir = Range("a" & Rows.Count).End(xlUp).Row
For i = 1 To ir Step 1
If Range("b" & i) = "" Then
'[a300].End(xlUp).Copy
[a300].End(xlUp).Delete
End If
Next i
Columns("A:H").EntireColumn.AutoFit
Columns("C:D").Select
Selection.Delete Shift:=xlToLeft
Range("a300").Select
Selection.End(xlUp).Select
last = ActiveCell.Row
Range("A2:g" & last).Select
'Sheets("Glass").[a1].CurrentRegion.Select
'Rows("1" & last).Select
Selection.RowHeight = 18.75
With Selection
.HorizontalAlignment = xlGeneral
.VerticalAlignment = xlCenter
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Range("A1:F1").Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.ColorIndex = xlAutomatic
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.ColorIndex = xlAutomatic
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.ColorIndex = xlAutomatic
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.ColorIndex = xlAutomatic
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlInsideVertical)
.LineStyle = xlContinuous
.ColorIndex = xlAutomatic
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlInsideHorizontal)
.LineStyle = xlContinuous
.ColorIndex = xlAutomatic
.TintAndShade = 0
.Weight = xlHairline
End With
Columns("D:D").Select
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
Range("D1").Select
ActiveCell.FormulaR1C1 = "Name"
Range("D2").Select
ActiveCell.FormulaR1C1 = "=RC[-3]&""""&RC[-2]&""""&RC[-1]"
Range("D3").Select
Range("D2").Select
Selection.AutoFill Destination:=Range("D2:D1000")
Range("D2:D1000").Select
Columns("D:D").EntireColumn.AutoFit
Rows("1:1").Select
Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
Range("a300").Select
Selection.End(xlUp).Select
last = ActiveCell.Row
Range("A2:g" & last).Select
'Sheets("Glass").[a2].CurrentRegion.Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlInsideVertical)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlInsideHorizontal)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlHairline
End With
Range("A2:G2").Select
Selection.Font.Bold = True
End Sub
พอรันแล้วจะได้หน้า Glass ค่ะ ตอนแรกไม่ทราบว่าจะมีชีทเพิ่ม เลยทำแบบใช้ลำดับชีทเลย ตอนนี้มีชีทเพิ่มเรื่อยๆ เลยต้องหาแนวทางการเขียนใหม่ค่ะ
[code]Sub Glass()
Application.ScreenUpdating = False
Dim last As Integer
Dim i As Integer
Dim ir As Long
Sheets(1).Select
Range("B5").Select
Selection.Copy
Sheets.Add After:=Sheets(Sheets.Count)
ActiveSheet.Name = "Glass"
'Sheets("Glass").Select
[a1] = "Panel"
[a300].End(xlUp).Offset(1, 0).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Sheets(1).Select
Range("o16").Select
Selection.End(xlUp).Select
last = ActiveCell.Row
Range("O7:U" & last).Select
'Range("J7:M" & a).Select
Selection.Copy
'Sheets.Add After:=Sheets(Sheets.Count)
Sheets("Glass").Select
Range("B1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
ir = Range("a" & Rows.Count).End(xlUp).Row
For i = 1 To ir Step 1
If Range("a" & i) <> "" Then
[a300].End(xlUp).Copy
[a300].End(xlUp).Offset(1, 0).Select
ActiveSheet.Paste
End If
Next i
ir = Range("a" & Rows.Count).End(xlUp).Row
For i = 1 To ir Step 1
If Range("b" & i) <> "" Then
[a300].End(xlUp).Copy
[a300].End(xlUp).Offset(1, 0).Select
ActiveSheet.Paste
End If
Next i
ir = Range("a" & Rows.Count).End(xlUp).Row
For i = 1 To ir Step 1
If Range("b" & i) = "" Then
'[a300].End(xlUp).Copy
[a300].End(xlUp).Delete
End If
Next i
'sheet2
Sheets(2).Select
Range("B5").Select
Selection.Copy
Sheets("Glass").Select
[a300].End(xlUp).Offset(1, 0).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Sheets(2).Select
Range("o16").Select
Selection.End(xlUp).Select
last = ActiveCell.Row
Range("O8:U" & last).Select
'Range("J7:M" & a).Select
Selection.Copy
'Sheets.Add After:=Sheets(Sheets.Count)
Sheets("Glass").Select
Range("B" & last).Select
[b100].End(xlUp).Offset(1, 0).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
ir = Range("a" & Rows.Count).End(xlUp).Row
For i = 1 To ir Step 1
If Range("a" & i) <> "" Then
[a300].End(xlUp).Copy
[a300].End(xlUp).Offset(1, 0).Select
ActiveSheet.Paste
End If
Next i
ir = Range("a" & Rows.Count).End(xlUp).Row
For i = 1 To ir Step 1
If Range("b" & i) <> "" Then
[a300].End(xlUp).Copy
[a300].End(xlUp).Offset(1, 0).Select
ActiveSheet.Paste
End If
Next i
ir = Range("a" & Rows.Count).End(xlUp).Row
For i = 1 To ir Step 1
If Range("b" & i) = "" Then
'[a300].End(xlUp).Copy
[a300].End(xlUp).Delete
End If
Next i
'sheet3
Sheets(3).Select
Range("B5").Select
Selection.Copy
Sheets("Glass").Select
[a300].End(xlUp).Offset(1, 0).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Sheets(3).Select
Range("o16").Select
Selection.End(xlUp).Select
last = ActiveCell.Row
Range("O8:U" & last).Select
'Range("J7:M" & a).Select
Selection.Copy
'Sheets.Add After:=Sheets(Sheets.Count)
Sheets("Glass").Select
Range("B" & last).Select
[b100].End(xlUp).Offset(1, 0).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
ir = Range("a" & Rows.Count).End(xlUp).Row
For i = 1 To ir Step 1
If Range("a" & i) <> "" Then
[a300].End(xlUp).Copy
[a300].End(xlUp).Offset(1, 0).Select
ActiveSheet.Paste
End If
Next i
ir = Range("a" & Rows.Count).End(xlUp).Row
For i = 1 To ir Step 1
If Range("b" & i) <> "" Then
[a300].End(xlUp).Copy
[a300].End(xlUp).Offset(1, 0).Select
ActiveSheet.Paste
End If
Next i
ir = Range("a" & Rows.Count).End(xlUp).Row
For i = 1 To ir Step 1
If Range("b" & i) = "" Then
'[a300].End(xlUp).Copy
[a300].End(xlUp).Delete
End If
Next i
[i5].Select
'sheet4
Sheets(4).Select
Range("B5").Select
Selection.Copy
Sheets("Glass").Select
[a300].End(xlUp).Offset(1, 0).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Sheets(4).Select
Range("o16").Select
Selection.End(xlUp).Select
last = ActiveCell.Row
Range("O8:U" & last).Select
'Range("J7:M" & a).Select
Selection.Copy
'Sheets.Add After:=Sheets(Sheets.Count)
Sheets("Glass").Select
Range("B" & last).Select
[b100].End(xlUp).Offset(1, 0).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
ir = Range("a" & Rows.Count).End(xlUp).Row
For i = 1 To ir Step 1
If Range("a" & i) <> "" Then
[a300].End(xlUp).Copy
[a300].End(xlUp).Offset(1, 0).Select
ActiveSheet.Paste
End If
Next i
ir = Range("a" & Rows.Count).End(xlUp).Row
For i = 1 To ir Step 1
If Range("b" & i) <> "" Then
[a300].End(xlUp).Copy
[a300].End(xlUp).Offset(1, 0).Select
ActiveSheet.Paste
End If
Next i
ir = Range("a" & Rows.Count).End(xlUp).Row
For i = 1 To ir Step 1
If Range("b" & i) = "" Then
'[a300].End(xlUp).Copy
[a300].End(xlUp).Delete
End If
Next i
'sheet5
Sheets(5).Select
Range("B5").Select
Selection.Copy
Sheets("Glass").Select
[a300].End(xlUp).Offset(1, 0).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Sheets(5).Select
Range("o16").Select
Selection.End(xlUp).Select
last = ActiveCell.Row
Range("O8:U" & last).Select
'Range("J7:M" & a).Select
Selection.Copy
'Sheets.Add After:=Sheets(Sheets.Count)
Sheets("Glass").Select
Range("B" & last).Select
[b100].End(xlUp).Offset(1, 0).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
ir = Range("a" & Rows.Count).End(xlUp).Row
For i = 1 To ir Step 1
If Range("a" & i) <> "" Then
[a300].End(xlUp).Copy
[a300].End(xlUp).Offset(1, 0).Select
ActiveSheet.Paste
End If
Next i
ir = Range("a" & Rows.Count).End(xlUp).Row
For i = 1 To ir Step 1
If Range("b" & i) <> "" Then
[a300].End(xlUp).Copy
[a300].End(xlUp).Offset(1, 0).Select
ActiveSheet.Paste
End If
Next i
ir = Range("a" & Rows.Count).End(xlUp).Row
For i = 1 To ir Step 1
If Range("b" & i) = "" Then
'[a300].End(xlUp).Copy
[a300].End(xlUp).Delete
End If
Next i
'sheet6
Sheets(6).Select
Range("B5").Select
Selection.Copy
Sheets("Glass").Select
[a300].End(xlUp).Offset(1, 0).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Sheets(6).Select
Range("o16").Select
Selection.End(xlUp).Select
last = ActiveCell.Row
Range("O8:U" & last).Select
Selection.Copy
Sheets("Glass").Select
Range("B" & last).Select
[b100].End(xlUp).Offset(1, 0).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
ir = Range("a" & Rows.Count).End(xlUp).Row
For i = 1 To ir Step 1
If Range("a" & i) <> "" Then
[a300].End(xlUp).Copy
[a300].End(xlUp).Offset(1, 0).Select
ActiveSheet.Paste
End If
Next i
ir = Range("a" & Rows.Count).End(xlUp).Row
For i = 1 To ir Step 1
If Range("b" & i) <> "" Then
[a300].End(xlUp).Copy
[a300].End(xlUp).Offset(1, 0).Select
ActiveSheet.Paste
End If
Next i
ir = Range("a" & Rows.Count).End(xlUp).Row
For i = 1 To ir Step 1
If Range("b" & i) = "" Then
'[a300].End(xlUp).Copy
[a300].End(xlUp).Delete
End If
Next i
'Sheet7
Sheets(7).Select
Range("B5").Select
Selection.Copy
Sheets("Glass").Select
[a300].End(xlUp).Offset(1, 0).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Sheets(7).Select
Range("o16").Select
Selection.End(xlUp).Select
last = ActiveCell.Row
Range("O8:U" & last).Select
Selection.Copy
Sheets("Glass").Select
Range("B" & last).Select
[b100].End(xlUp).Offset(1, 0).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
ir = Range("a" & Rows.Count).End(xlUp).Row
For i = 1 To ir Step 1
If Range("a" & i) <> "" Then
[a300].End(xlUp).Copy
[a300].End(xlUp).Offset(1, 0).Select
ActiveSheet.Paste
End If
Next i
ir = Range("a" & Rows.Count).End(xlUp).Row
For i = 1 To ir Step 1
If Range("b" & i) <> "" Then
[a300].End(xlUp).Copy
[a300].End(xlUp).Offset(1, 0).Select
ActiveSheet.Paste
End If
Next i
ir = Range("a" & Rows.Count).End(xlUp).Row
For i = 1 To ir Step 1
If Range("b" & i) = "" Then
'[a300].End(xlUp).Copy
[a300].End(xlUp).Delete
End If
Next i
Columns("A:H").EntireColumn.AutoFit
Columns("C:D").Select
Selection.Delete Shift:=xlToLeft
Range("a300").Select
Selection.End(xlUp).Select
last = ActiveCell.Row
Range("A2:g" & last).Select
'Sheets("Glass").[a1].CurrentRegion.Select
'Rows("1" & last).Select
Selection.RowHeight = 18.75
With Selection
.HorizontalAlignment = xlGeneral
.VerticalAlignment = xlCenter
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Range("A1:F1").Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.ColorIndex = xlAutomatic
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.ColorIndex = xlAutomatic
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.ColorIndex = xlAutomatic
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.ColorIndex = xlAutomatic
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlInsideVertical)
.LineStyle = xlContinuous
.ColorIndex = xlAutomatic
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlInsideHorizontal)
.LineStyle = xlContinuous
.ColorIndex = xlAutomatic
.TintAndShade = 0
.Weight = xlHairline
End With
Columns("D:D").Select
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
Range("D1").Select
ActiveCell.FormulaR1C1 = "Name"
Range("D2").Select
ActiveCell.FormulaR1C1 = "=RC[-3]&""""&RC[-2]&""""&RC[-1]"
Range("D3").Select
Range("D2").Select
Selection.AutoFill Destination:=Range("D2:D1000")
Range("D2:D1000").Select
Columns("D:D").EntireColumn.AutoFit
Rows("1:1").Select
Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
Range("a300").Select
Selection.End(xlUp).Select
last = ActiveCell.Row
Range("A2:g" & last).Select
'Sheets("Glass").[a2].CurrentRegion.Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlInsideVertical)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlInsideHorizontal)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlHairline
End With
Range("A2:G2").Select
Selection.Font.Bold = True
End Sub
[/code]
พอรันแล้วจะได้หน้า Glass ค่ะ ตอนแรกไม่ทราบว่าจะมีชีทเพิ่ม เลยทำแบบใช้ลำดับชีทเลย ตอนนี้มีชีทเพิ่มเรื่อยๆ เลยต้องหาแนวทางการเขียนใหม่ค่ะ