supper's ready
New Member
- Joined
- Jun 3, 2011
- Messages
- 23
hello,
i have the following code:
i want to add code that will add an if statement to a sub called Sub CreateWorkbooks() (in module 1) for each instance of the loop.
The if statement will take a column address from C3:C17 (where c3 corresponds to b3 instance etc) to define a variable.
heres what the if statement looks like:
please please help! thanks!
i have the following code:
Code:
Sub MakeSheets()
Dim ListofNames As Range
Dim c As Range
Set ListofNames = ActiveSheet.[B3:B17]
For Each c In ListofNames
If c.Text <> vbNullString Then
On Error GoTo InvalidName
ThisWorkbook.Sheets.Add After:=Sheets(Sheets.Count)
ActiveSheet.Name = c.Value
NextC:
End If
Next
Exit Sub
InvalidName:
MsgBox """" & c.Value & """ is an invalid sheet name.", vbOKOnly + vbCritical, "Add Sheets"
Resume NextC
End Sub
i want to add code that will add an if statement to a sub called Sub CreateWorkbooks() (in module 1) for each instance of the loop.
The if statement will take a column address from C3:C17 (where c3 corresponds to b3 instance etc) to define a variable.
heres what the if statement looks like:
Code:
If Sheet.Name = "value from b3 Then
Columns("B:B").Select 'B:B comes from value in C3
Selection.NumberFormat = "m/d/yyyy"
dtMin = WorksheetFunction.Min(Columns("B:B"))
dtMax = WorksheetFunction.Max(Columns("B:B"))
DayMin = Day(dtMin)
DayMax = Day(dtMax)
End If
please please help! thanks!