Populating cells within a dynamic table

Lethal81

New Member
Joined
Apr 10, 2017
Messages
16
So I have the following code....I am fairly novice so I am not sure this is even the most effective way to do this

Sub BuildTable()
Application.ScreenUpdating = False
Dim copySheet AsWorksheet
Dim pasteSheet AsWorksheet
Dim LastRow As Long


Set copySheet =Worksheets("Combined Data")
Set pasteSheet =Worksheets("Pivot Tables")
LastRow =Worksheets("Pivot Tables").Range("B" & Rows.Count).End(xlUp).Row+ 2


Worksheets("Pivot Tables").Range("B" & LastRow)= 1
Worksheets("Pivot Tables").Range("B" &LastRow).Select
Selection.DataSeriesRowcol:=xlRows, Type:=xlLinear, Date:=xlDay, _
Step:=1,Stop:=12, Trend:=False


copySheet.Range("I3:I5000").Copy

pasteSheet.Cells(Rows.Count, 1).End(xlUp).Offset(3, 0).PasteSpecialxlPasteValues

pasteSheet.Range("A" & Cells(Rows.Count, 1).End(xlUp).Row+ 1).RemoveDuplicates Columns:=1, Header:=xlNo



Application.CutCopyMode = False

Application.ScreenUpdating = True



End Sub

What this is doing is creating a "table" which uses unique values pulled from a column of a data table to create the "y" axis in column A, and the numbers 1-12 for the "x" axis one row above and one column over from were the "y" starts. Both of these move in relation to last row, because pivot tables populate the top half of this worksheet, and can adjust in size, and this table places itself below them.

Here is what I can't get to work. I need to fill in the area created by the variable y axis, and the static 1-12 in the x axis, with a formula. I have been able to get this to work based on cell references, but I can't figure out how to get it to adjust in relation to the y axis. I am not married to the existing code if there is a better way. Any help would be appreciated, thank you in advance.



 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.

Forum statistics

Threads
1,224,823
Messages
6,181,175
Members
453,021
Latest member
Justyna P

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