Formula does not populate the correct column

Brutium

Board Regular
Joined
Mar 27, 2009
Messages
188
Hello all,

Thanks to the help of someone else in this forum I was able to partially solve my dilemma.

I have a formula which creates sheets based on a template, and then populate a summary sheet. Unfortunately the columns that the macro fills up are not he correct ones. The macro fills up starting from a column to the right of where it should start from. I cannot make my macro start correctly.

Any help would be GREATLY appreciated.

Thank you
Brutium
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
Hello PaddyD

This is the macro I am using:
Sub Addsheets()
Dim LR As Long, i As Long, MasterSheet As Long
Dim rngTopOfList As Range
Dim wsName As String
Dim n As Integer

n = 1
With Sheets("tools")

Set rngTopOfList = .Range("B3")

LR = .Cells(.Rows.Count, rngTopOfList.Column).End(xlUp).Row

MasterSheet = ActiveWorkbook.Sheets.Count

If LR > rngTopOfList.Row Then

For i = 1 To LR - rngTopOfList.Row
ActiveWorkbook.Sheets(MasterSheet).Copy _
after:=Worksheets(MasterSheet + i - 1)
ActiveWorkbook.Sheets(MasterSheet + i).Name = _
rngTopOfList.Offset(i).Value '''Can be replaced with wsName if the following line is moved before.

''' Here begins changes
wsName = rngTopOfList.Offset(i).Value

ActiveWorkbook.Sheets("Class").Range("C9").Offset(0, n).Value = _
"=" & wsName & "!M9"
n = n + 1
'''
Next i

End If

ActiveWorkbook.Sheets(MasterSheet).Name = rngTopOfList.Value
End With
Set rngTopOfList = Nothing
End Sub

As I said it starts populating in the wrong column. It should start from C9.

Any idea on how I can solve this?

Brutium
 
Upvote 0
vba's not really my thng but try:

ActiveWorkbook.Sheets("Class").Range("B9").Offset(0, n).Value = _

...instead of:

ActiveWorkbook.Sheets("Class").Range("C9").Offset(0, n).Value = _
 
Upvote 0
No PaddyD,

It did not work. All it did was shift my inputs to the right. What I need to do is have the same formula that I created for the row 9 to replicate down. I copied the formula down, but it did not work since the code does not know the sheets that are created by the macro (I think).

Brutium
 
Upvote 0

Forum statistics

Threads
1,215,693
Messages
6,126,248
Members
449,305
Latest member
Dalyb2

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