当我粘贴通过VBA代码从过滤范围复制的Amount数据时,没有得到正确的结果。 如何在VBA中复制并粘贴正确的过滤范围?
我已经尝试了很多方法,例如可见单元格和调整大小。
let routesRef = firebase.database().ref('/routes');
let passengersRef = firebase.database().ref('/passengers');
// push to Route
routesRef.push(routeDataHere);
// push to Passenger
passengerRef.push(passengerDataHere);
// listen to added Route
routesRef.on('child_added', (snapshot) => {
let data = snapshot.val();
let pickup = data.pickup;
let destination = data.destination;
let time = data.time
});
// listen to added Passenger
passengerRef.on('child_added', (snapshot) => {
let data = snapshot.val();
let name = data.name;
let passengers = data.passengers;
});
几乎有22个数量,但我只有10个数量。
答案 0 :(得分:0)
您需要添加变量以引用这两个工作簿,但是希望该示例可以工作。
Sub CopyPasteFilteredRange()
Dim D As Worksheet
Dim Log As Worksheet
Dim PasteHere As Worksheet
Dim Rangedata As range, U As range
Dim Lastrow As Long 'Get Last Row
Set D = Worksheets("D")
Set Log = Worksheets("Log")
Set PasteHere = Worksheets("PasteHere") 'Added Sheet PasteHere as Example
'Remove Filtered Criteria Before Filtering
If ActiveSheet.FilterMode Then
ActiveSheet.ShowAllData
End If
'Table Range
Set Rangedata = D.range("A1:C" & range("A1").End(xlDown).Row)
Rangedata.AutoFilter Field:=2, Criteria1:=Log.Cells(8, 3)
'Amount which i want to copy without Header
'If you have filtered above on Column B, but if there are blank cells in Col C .End(XlDown will stop at first blank value, so add lastRow to capture all used rows
Lastrow = D.UsedRange.Rows(D.UsedRange.Rows.Count).Row
Set U = D.range("C1:C" & Lastrow)
'Set U to Visable Cells otherwise what you are .copying is still = D.range("C1:C" & range("C1").End(xlDown).Row)
Set U = U.Offset(1, 0).SpecialCells(xlCellTypeVisible)
U.Copy 'Don't have to Select U
PasteHere.range("A1").PasteSpecial
End Sub