SELECT id
FROM myDataset.users
WHERE account_id = 'ACCOUNT_ID'
-- Correlated subqueries error
AND EXISTS(
SELECT SUM(counter) visit_count_total
FROM myDataset.pageviews
WHERE user_id = users.id
AND visit_date >= DATE_SUB(CURRENT_DATE(), INTERVAL 1 WEEK)
AND visit_path = '/pricing'
HAVING visit_count_total >= 10
LIMIT 1
)
-- Correlated subqueries error
AND EXISTS(
SELECT SUM(counter) visit_count_total
FROM myDataset.pageviews
WHERE user_id = users.id
AND visit_date >= DATE_SUB(CURRENT_DATE(), INTERVAL 1 DAY)
AND visit_path = '/contact'
HAVING visit_count_total >= 1
LIMIT 1
)
LIMIT 100
我正在尝试在CA列的+1偏移行中插入小计公式,并将其扩展到DO列(最后一列)。
我将如何进行更新呢?
我还如何更改此设置以反映那些动态行/列?
Sub Top10()
Dim rngRows As Range, rngCols As Range
LastRow = Range("CA" & Rows.Count).End(xlUp).Row
Set rngRows = Range("CA" & LastRow + 1)
Set rngCols = rngRows & columns.count
End Sub
如何在条件格式代码中实现lastrow / lastcolumn内容?
答案 0 :(得分:4)
这是第一个答案:
Sub Top10()
Dim ws As Worksheet
Set ws = Worksheets("Sheet1") 'Change to your sheet
Dim LastRow As Long
LastRow = Range("CA" & Rows.Count).End(xlUp).Row
Dim LastCol As Long
LastCol = ws.Cells(LastRow, ws.Columns.Count).End(xlToLeft).Column
'This will sum everything from row 2 to the last used row.
'Change the 2 in the formula to your first row.
ws.Range(ws.Cells(LastRow + 1, "CA"), ws.Cells(LastRow + 1, LastCol)).Formula = "=SUM(CA2:CA" & LastRow & ")"
End Sub