blackhawk56z
New Member
- Joined
- May 25, 2016
- Messages
- 8
Hi I am a total newbie at VBA and I have searched the forum quite extensively but haven't found anything that is specific to what I need.
I have created a multi-select listbox (activeX control) in which I displayed the names of each worksheet. What I need for the command button is to help me clear contents (Range "B2:B15" and Range "D3:D5") for a range of cells in those worksheets that I have selected in the listbox.
Most threads here keep throwing me solutions on how to clear the contents in the listboxes themselves instead of what i need.
Below is my code:
I have created a multi-select listbox (activeX control) in which I displayed the names of each worksheet. What I need for the command button is to help me clear contents (Range "B2:B15" and Range "D3:D5") for a range of cells in those worksheets that I have selected in the listbox.
Most threads here keep throwing me solutions on how to clear the contents in the listboxes themselves instead of what i need.
Below is my code:
Code:
Private Sub clrcnt_click()
Worksheets(ListBox1.MultiSelect).ClearContents
End Sub
Sub UserForm_Initialize()
Dim N As Long
For N = 2 To ActiveWorkbook.Sheets.Count
ListBox1.AddItem ActiveWorkbook.Sheets(N).Name
Next N
End Sub
[\code]
Forgive me if this looks stupid I just started learning vba for a few days only.