Good day,
i have a bit of code that was made. currently the scrip works great. little dirty but it works with a few exceptions that have came up.
need to add a section for detecting if the name for the new sheet already exist before the creating of the new sheet if possible. (this may take care of the error handling section)
then some of the code i just don't understand. (explain if possible) see remarks in code block.
also this code is only ran when the command button is activated, and only on the main sheet "SPMIG",
the copy sheet is named "MASTER_SPMIG" and the
renaming is from a $A (and what ever row it is active)
any questions please ask.
example of data
i have a bit of code that was made. currently the scrip works great. little dirty but it works with a few exceptions that have came up.
need to add a section for detecting if the name for the new sheet already exist before the creating of the new sheet if possible. (this may take care of the error handling section)
then some of the code i just don't understand. (explain if possible) see remarks in code block.
also this code is only ran when the command button is activated, and only on the main sheet "SPMIG",
the copy sheet is named "MASTER_SPMIG" and the
renaming is from a $A (and what ever row it is active)
any questions please ask.
VBA Code:
Sub AddWorksheetsFromSelection()
Dim CurSheet As Worksheet
Dim Source As Range
Dim c As Range
Sheets("SPMIG").Select
ActiveSheet.Cells(ActiveCell.Row, ActiveCell.CurrentRegion.Columns(1).Column).Select'<---------- moves to first column of the active cell in SPMIG work sheet
Set CurSheet = ActiveSheet
Set Source = Selection.Cells
Application.ScreenUpdating = False '<------- what is this???
For Each c In Source '<------- why loop when only doing 1 sheet.
sName = Trim(c.Text)
If Len(sName) > 0 Then
Sheets("Master_SPMIG").Copy after:=Sheets("SPMIG")
ActiveSheet.Name = sName + "_SPMIG"
End If
Next c
CurSheet.Activate
Application.ScreenUpdating = True
End Sub
example of data
HQ2F | what ever is here | not of concern |
HE3F | what ever is here | not of concern |