[英]Copy values to new sheet after the last sheet and delete column b if empty
I want to copy only the values (not formulas) of the last sheet of any workbook I run the macro on (I won't know the names of sheets or quantity of sheets) and to delete the B column if it's blank and name this new wirksheet "Games". 我只想复制在其上运行宏的任何工作簿的最后一张纸的值(而不是公式)(我不知道纸的名称或纸的数量),并删除B列(如果其为空白)并将其命名为新的工作表“游戏”。 This is what I have and it's not working =(. Could anyone give me a help?
这就是我所拥有的,它不起作用=(。有人可以给我帮助吗?
Sub ArrumarTabela()
ActiveSheet.Copy
Cells.Copy
Application.CutCopyMode = False
ActiveSheet.Name = "Games"
Range("A1").PasteSpecial Paste:=xlPasteValues
Application.ScreenUpdating = False
ActiveSheet.Name = "Games"
Dim cl As Range
For Each cl In Range("$B$2:$B" & Range("$B$65536").End(xlUp).Row)
If cl = "" Then cl.EntireColumn.Delete
Next cl
Range("C1").Select
Selection.EntireColumn.Insert , CopyOrigin:=xlFormatFromLeftOrAbove
Application.ScreenUpdating = True
End Sub
Will this modification do what you need? 这项修改会满足您的需求吗?
Sub ArrumarTabela()
ActiveSheet.Copy 'this will create a new workbook and a new sheet with current
With ActiveSheet
.Name = "Games" 'change new sheets name
.Cells.Copy 'copy all cells
.Range("A1").PasteSpecial Paste:=xlPasteValues 'paste only values
.ScreenUpdating = False
lastrow = .Cells(.Rows.Count, "B").End(xlUp).Row 'last row?
Set cl = .Range("B2:B" & lastrow).Find("", lookat:=xlWhole) 'find a blank cell in a range
If Not cl Is Nothing Then cl.EntireColumn.Delete 'delete column if blank exists
.Range("C1").EntireColumn.Insert 'insert new column belfore column C
.ScreenUpdating = True
End With
End Sub
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.