Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- https://excel-egy.com/forum/t4521
- ---------------------------------
- Private Sub UserForm_Initialize()
- With Me.ListBox1
- .AddItem "salem"
- .AddItem "ahmad"
- .AddItem "nyef"
- .AddItem "rami"
- End With
- End Sub
- Private Sub CommandButton1_Click()
- Dim ws As Worksheet, b As Boolean, s As String, x As Integer
- For x = 0 To ListBox1.ListCount - 1
- If ListBox1.Selected(x) = True Then
- s = ListBox1.List(x): b = False
- For Each ws In Worksheets
- If ws.Name = s Then b = True: Exit For
- Next ws
- If b = True Then
- Application.Goto Sheets(s).Range("A1"): [A1] = Date
- Else
- Worksheets.Add(After:=Worksheets(Worksheets.Count)).Name = s: [A1] = Date
- Columns(1).AutoFit
- End If
- End If
- Next x
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement