Filling Out Worksheets Using Loop and Variables

patticlaire

New Member
Joined
Jun 15, 2018
Messages
6
I have a publicly defined list of PMs (PM is a class). A PM object has a name, group, and pin. I have 6 worksheets that are named at "PM Name - Indicators" where the PM Name is the name of whatever object. The PMs have projects assigned to them (project is also a class object).

I am trying to update each of the six sheets with the PM's assigned projects. The bolded line is throwing a runtime error 91, but I can't figure out why

Public Sub updatePMSheets()
Dim aWorksheet As String
Dim startcell As Range
Dim i As Integer
Dim sheetName As String

For Each aPM In PMList
aWorksheet = aPM.GetName & " - Indicators"
startcell = Worksheets(aWorksheet).Range("B2")
For i = 1 To aPM.ProjectCount
startcell.Offset((i - 1), 0).Value = aPM.GetProject(i)
Next
Next
End Sub
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
Welcome to Mr Excel forum

startcell is a an Object Variable (Range) so see if this works
Set startcell = Worksheets(aWorksheet).Range("B2")

M.
 
Upvote 0

Forum statistics

Threads
1,214,907
Messages
6,122,181
Members
449,071
Latest member
cdnMech

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