Dynamic AutoFill

datauser

New Member
Joined
Sep 4, 2024
Messages
23
Office Version
  1. 365
Platform
  1. Windows
Hello!

I need some help figuring out what I am missing here. I am trying to autofill a selection down the rows where the starting point of my autofill is dynamic and the ending point of my autofill is also dynamic.

Dim lastRowB As Long

lastRowB = ws.Cells(ws.Rows.Count, 2).End(xlUp).Row

ws.Cells(lastRowB + 4, 2).Formula2 = "=UNIQUE(TOCOL(Query2!C:C,1))"
ws.Cells(lastRowB + 4, 3).Formula2 = "=TRANSPOSE( UNIQUE(Query2[ID]))"

WDate = ws.Cells(lastRowB + 5, 2).Address(False, True) This is the "Week Beginning Dates"
PB = ws.Cells(lastRowB + 4, 3).Address(True, False) This is the "25530"

'ws.Cells(lastRowB + 5, 3).Formula2 = "= " & PB & ""
ws.Cells(lastRowB + 5, 3).Formula2 = "=SUMIFS(Query2[Total],Query2[ID]," & PB & ",Query2[''Dates'']," & WDate & ")"
StartCell = ws.Cells(lastRowB + 5, 3).Address
StartCell.AutoFill Range("" & StartCell & " :C" & Range("B" & Rows.Count).End(xlUp).Row)

1730438752351.png

Any Help is appreciated!
 

Attachments

  • 1730438729541.png
    1730438729541.png
    23.1 KB · Views: 4

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
No it is still an image, you need to either install the forums XL2BB addin or upload a sanitized file to a free file hosting site like www.box.com or www.dropbox.com (if doing this remember to mark it for sharing and post the link it then provides in the thread).

Preferably install XL2BB

 
Upvote 0
WIP - Copy11.18.2024.xlsm
ABCDEF
10
11
12'Week Beginning Dates'25530269892818226457
131/22/20240.5000
141/29/2024
152/5/2024
162/12/2024
172/19/2024
184/29/2024
195/6/2024
205/13/2024
215/20/2024
225/27/2024
236/3/2024
246/10/2024
256/17/2024
266/24/2024
277/1/2024
287/8/2024
297/15/2024
307/22/2024
317/29/2024
328/5/2024
338/12/2024
348/19/2024
358/26/2024
Budget Summary
Cell Formulas
RangeFormula
B12:B44B12=UNIQUE(TOCOL(Query2!C:C,1))
C12:F12C12=TRANSPOSE(UNIQUE(Query2[ProjectBudgetID]))
C13C13=SUMIFS(Query2[Total],Query2[ProjectBudgetID],$C12,Query2[''Week Beginning Dates''],$B13)
D13D13=SUMIFS(Query2[Project],Query2[''Team Members''],$C12,Query2[Total],$B13)
E13E13=SUMIFS(Query2[Updated],Query2[''Week Beginning Dates''],$C12,Query2[Project],$B13)
F13F13=SUMIFS(Query2[BudgetYear],Query2[Total],$C12,Query2[Updated],$B13)
Dynamic array formulas.
 
Upvote 0
Also in the code I posted it looks like
VBA Code:
 lColrow = lastRowB + 4
should be just
VBA Code:
lColrow = lastRowB
 
Upvote 0

Forum statistics

Threads
1,223,856
Messages
6,175,027
Members
452,604
Latest member
cballetti

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top