[英]Macro Excel to copy range cells from one sheet to another based on cell match and skip cell if no match
[英]Excel Macro & VBA, Copy Cell Range to another sheet (transposed and based on another value)
我曾尝试从不同的线程开始弗兰肯斯坦的解决方案,但我是VBA和编程的新手,因此进展不太顺利...
以下是一些基本信息:
现在,我正在寻找3件事(最好是在一个紧凑的解决方案中)
有一个命令按钮,用于将最新范围(最左边的列)从数据输入复制并转置到数据库。 (这在下面的代码中完成)
应当根据数据输入表上的某个单元格值执行此操作(理想情况下,该单元格可以保留复制范围的一部分,但这并不重要)
从数据输入表中删除原始范围。
正如我说过的那样,我刚开始使用VBA,所以我完全不确定该怎么做,我已经附加了到目前为止收集到的内容(不包括Nr.2,总体上感觉非常麻烦)。 很感谢任何形式的帮助!
Private Sub CommandButton1_Click()
Application.ScreenUpdating = False
Dim xSheet As Worksheet
Set xSheet = ActiveSheet
If xSheet.Name <> "Definitions" And xSheet.Name <> "fx" And xSheet.Name <> "Needs" Then
xSheet.Range("E6:E200").Copy
Worksheets("Sheet1").Range("E6:AZ6").PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=True
End If
Application.ScreenUpdating = True
End Sub
检查这一。 它检查E10的值。 如果为“ Y”,则从原始位置复制和删除数据。 否则,它会向用户显示一条消息。
Private Sub CommandButton1_Click()
Application.ScreenUpdating = False
Dim xSheet As Worksheet
Set xSheet = ActiveSheet
If xSheet.Name <> "Definitions" And xSheet.Name <> "fx" And xSheet.Name <> "Needs" Then
If xSheet.Range("E10")="Y"
xSheet.Range("E6:E200").Copy
Worksheets("Sheet1").Range("E6:AZ6").PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=True
xSheet.Columns("E").Delete
Else
MsgBox("Data entry not ready!")
End If
End If
Application.ScreenUpdating = True
End Sub
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.