HElp with code object/dynamic name

megadentalda

New Member
Joined
Jan 30, 2017
Messages
22
Please need some help with codign this last bit (bolded areas are the problem):
1st bold issue is that I need the cell value of "lastrowm" to be used in part of a formula. So if my cells are in column B then formula is C2/C20 if lastrowm is 20...

2nd bold issue is placement of a pivot table but again using value last rowm as this database changes constantly and need dynamic placement to keep it in same format.

any help greatly appreciated!!!

thank you in advance

Sheets("Results Table").Select
lastrowm = ActiveSheet.Range("A2").Offset.End(xlDown).Row
Range("B1:B" & lastrowm).Select
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
Selection.NumberFormat = "General"
Range("B1").Select
Range("B1").Value = "% per Rep"
For Each Cell In Range("B2:B" & lastrowm)
Cell.Value = "=rc[+1]/c & Lastrowm"
Next
Range("B2:B" & lastrowm).Select
Selection.Style = "Percent"
Sheets("Base de datos").Select
Range("F1").Value = "Ref"
Columns("E:K").Select
ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
"Base de datos!R1C5:R1048576C11", Version:=6).CreatePivotTable _
TableDestination:="Results Table!G & lastrowm + 6", TableName:="PivotTable2", _
DefaultVersion:=6
Sheets("Results Table").Select
Cells(G & lastrowm + 6).Select
With ActiveSheet.PivotTables("PivotTable2")
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
Please any help would be greatly appreciated!! Desperate to finish this code.... Is there anything else you need from me to help me complete task...??

Again thanks to anyone who reads and comments
 
Upvote 0

Forum statistics

Threads
1,215,078
Messages
6,122,996
Members
449,093
Latest member
masterms

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