HI, Here is the required macro to search a field and if value found copy the whole row into another...
I found a solution like this :Records in between two specific dates easily can be filtered using drop-down lists ....
I found a solution as follows: Watch the video to see how it's done and download example file : https://youtu.be/SZduAoOtiS0
I have sorted the above problem. Code is given below... [code] Sub seperate() Call CleanSheets MsgBox "1 of 10 Cleaning...
Hi, Here is the VBA code to Split the Workbook into different Files by Each Sheet in the file and...
Hi, You can loop through the Sheet using Workbook Sheets Collection. See the Updated Code below: [code] Sub sbDeleteRows() 'Array...
Hi, We can follo several methods to fill the unique values from the worksheet to ListBox. Here is my preferred...
I have total 20 columns in sheet1,
First – 8 columns are – region, Dept, leader, manager, product,subprodcut, employee name, employee type,
12 columns are 12 months (Jan – Dec)
I need the userform – where user can select any of the above first – 8 columns (single or multiple),
Once the list item selected, only those columns should paste in sheet2 along with 12 months data,
Need solution very badly 🙁
Here is the solution for your query to get columns data from Sheet1 to Sheet2 based on list box selection.
Here are the instructions.
Private Sub CommandButton1_Click()
Dim iCnt As Integer
Dim MyHdr() As String, count As Integer, lastRow As Integer, destCol As Integer
count = 0: destCol = 1
For iCnt = 0 To Me.ListBox1.ListCount - 1
If Me.ListBox1.Selected(iCnt) = True Then
ReDim Preserve MyHdr(count)
MyHdr(count) = ListBox1.List(iCnt)
count = count + 1
'Find last row in Sheet1
lastRow = Sheet1.Cells.SpecialCells(xlLastCell).Row
For i = LBound(MyHdr) To UBound(MyHdr)
shdr = MyHdr(i)
For j = 1 To 8
If Sheet1.Cells(1, j) = shdr Then
Sheet1.Range(Sheet1.Cells(1, j), Sheet1.Cells(lastRow, j)).Copy Destination:=Sheet2.Cells(1, destCol)
destCol = destCol + 1
'Move Jan to Dec Data to Sheet2
Sheet1.Range(Sheet1.Cells(1, 9), Sheet1.Cells(lastRow, 20)).Copy Destination:=Sheet2.Cells(1, destCol)
Private Sub UserForm_Initialize()
For i = 1 To 8
ListBox1.AddItem Sheet1.Cells(1, i)
Hope it clarifies your query.
No words, just Awesome!!!!! exactly what i wanted , saved me a lot of time, thank you sooo much,
really great!!, worth joining this forum :):):)
I need one small extension here, apologies for that –
Can I get columns pattern/series based on the user’s selection – Ex –
1st instance – user select Dept first and then manger – here col 1 is Dept and col 2 is manager
2nd instance – user select manger first and then Dept ( vice -versa) here col 1 is manager and col 2 is Dept
and goes on
thanks in advance,
Here is some useful information about the ListBox.
Once the columns pasted in sheet2, i need those columns to subtotal and show only total rows (similar to subtotal level 2 ), please help,, this will end my complete project.
Please share using the share button above.
If you found the answer is best answer for your question, Please mark as 'best answer' by clicking on the right tick mark icon at the left side of the answer.
Found the answer useful and wants to credit the user, then vote the answer (vote up).