'SHEETS
For Each ctrl As Control In Me.Controls
What am I doing wrong here? When I put in manual text after the line return it fill in but as is it doesn't pick up all the checkboxes under HEADINGS. It does create all the sheets under SHEETS.
Code:If (TypeOf ctrl Is CheckBox AndAlso CType(ctrl, CheckBox).Checked) AndAlso CType(ctrl, CheckBox).Name.Contains("Sheet") Then wb.Worksheets("Template").copy(after:=sheet) sheet = wb.ActiveSheet sheet.Name = CType(ctrl, CheckBox).Text 'HEADINGS *******ONLY CATCHING 1ST HEADING ON EACH SHEET******* For Each head As Control In Me.Controls If (TypeOf head Is CheckBox AndAlso CType(head, CheckBox).Checked) AndAlso CType(head, CheckBox).Name.Contains("Head" & sheet.Name) Then sheet.Range("E31").Select() excel.ActiveCell.Value2 = CType(head, CheckBox).Text 'LINE RETURN excel.ActiveCell.Offset(+1, 0).Select() End If Next End If Next




Reply With Quote