[英]Copying from one sheet to another using buttons based on value
I'm using microsoft excel 2013. 我正在使用Microsoft Excel 2013。
So i have two sheets. 所以我有两张。 "Cases" and "Summarize". “案例”和“摘要”。 All of my important info is on the Cases sheet. 我所有重要的信息都在“案例”表中。 Is there way i can be on the "Summarize" sheet, push a button and copy all the cellrows with the value "RLH" from cases over to the summarize sheet? 有什么办法可以将我放在“摘要”表上,按一下按钮,然后将所有案例中值为“ RLH”的所有单元格复制到摘要表中?
I've filled the entire row up to N. And i want that entire row to be copied into the summarize sheet when I push the button. 我已经将整行填满到N。并且我希望在按下按钮时将整行复制到摘要表中。 The "RLH" value is on the N(last) column. “ RLH”值在N(最后)列上。
I know how to create the button and how to insert the code. 我知道如何创建按钮以及如何插入代码。 I've been googling my ass of, but I cant seem to find anything that fits me. 我一直在搜寻自己的屁股,但似乎找不到适合自己的东西。
All help is greatly appreciated. 非常感谢所有帮助。
Here is very simple. 这很简单。 that will get you started 那会让你入门
Option Explicit
Sub Mybutton()
'// declare a variable
Dim cRng As Range
Dim rngA As Long
Dim rngB As Long
Dim Cols As Long
Dim sCases As Worksheet
Dim sSummarize As Worksheet
'// Set the sheets name
Set sCases = Sheets("Cases")
Set sSummarize = Sheets("Summarize")
'// goes through each cell in Sheets"Cases"
'// and copes the Value "RLH" to Sheets"Summarize"
'// it starts from last row in column A & looks up
rngA = sCases.Cells(Rows.Count, "N").End(xlUp).Row
Cols = sCases.UsedRange.Columns.Count
For Each cRng In sCases.Range("A2:A" & rngA)
If cRng.Value = "RLH" Then '<<<<<<<<< Value = "RLT"
rngB = sSummarize.Cells(Rows.Count, "A").End(xlUp).Row + 1
sSummarize.Range("A" & rngB).Resize(1, Cols) = cRng.Resize(1, Cols).Value
End If
'// loop
Next cRng
Set sSummarize = Nothing
Set sCases = Nothing
End Sub
hope this helps 希望这可以帮助
you may also find help full on the following link MSDN Getting Started with VBA . 您还可以在以下链接“ MSDN VBA入门”中找到完整的帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.