in Education by
How do I transfer data from a worksheet to another based on a specific cell value? I tried several different VBA codes but I must be honest; I only have basic knowledge of VBA codes. The case is, I have one worksheet, which is a register of a lot of information, and I want to transfer specific data from each row based on one specific cell value in the same row. For example in Column L, I have the option via a dropdown menu to select "Yes - Urgent", "Yes" and "No". If it is "Yes - Urgent" or "Yes", I want it to automatically transfer some of the data to two separate worksheets. For example cell A, C, E and G of the same row that has "Yes" and transferred to B, D, E and F in a separate worksheet. FYI, in the Excel workbook there is headers in all worksheets with filters. It's the filters that's bugging me specifically. I use Microsoft Office 2010. JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
I believe something like this will work: 'declaring variables Dim sheet1 As Worksheet Dim sheet2 As Worksheet Dim sheet3 As Worksheet Dim new_row As Long 'setting sheets Set sheet1 = ThisWorkbook.Sheets("Sheet 1") Set sheet2 = ThisWorkbook.Sheets("Sheet 2") Set sheet3 = ThisWorkbook.Sheets("Sheet 3") 'loop (starts at row 2 because of headers) For Each cell In sheet1.Range(sheet1.Cells(2, 12), sheet1.Cells(Rows.Count, 12).End(xlUp)) If cell.Value = "Yes - Urgent" Or cell.Value = "Yes" Then 'first empty cell in sheet 2 (assuming column A always has a value) new_row = sheet2.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0) 'sheet1-A to sheet2-B sheet2.Cells(new_row, 2) = sheet1.Cells(cell.Row, 1) 'sheet1-C to sheet2-D sheet2.Cells(new_row, 4) = sheet1.Cells(cell.Row, 3) 'sheet1-E to sheet2-E sheet2.Cells(new_row, 5) = sheet1.Cells(cell.Row, 5) 'sheet1-G to sheet2-F sheet2.Cells(new_row, 6) = sheet1.Cells(cell.Row, 7) ElseIf cell.Value = "No" Then 'first empty cell in sheet 3 (assuming column A always has a value) new_row = sheet3.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0) 'sheet1-A to sheet3-B sheet3.Cells(new_row, 2) = sheet1.Cells(cell.Row, 1) End If Next cell

Related questions

0 votes
    How do I transfer data from a worksheet to another based on a specific cell value? I tried several ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 22, 2022 in Education by JackTerrance
0 votes
    I have encountered a problem during my work. There are over one hundred worksheets in my excel, and I ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 7, 2022 in Education by JackTerrance
0 votes
    I am trying to adjust the row height based on the cell value. The operation have to run through ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 1, 2022 in Education by JackTerrance
0 votes
    I have a column array with the following values in my sheet: 11, 15, 5, 7, 2. I want to ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 11, 2022 in Education by JackTerrance
0 votes
    I have a column array with the following values in my sheet: 11, 15, 5, 7, 2. I want to ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 11, 2022 in Education by JackTerrance
0 votes
    I have two sheets sheet1, sheet2. Sheet2 having the with records and duplicate number. like sheet1 1--- ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 16, 2022 in Education by JackTerrance
0 votes
    We have over 10 computers on our network and everyone's computer opens up the file with no issue. ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 13, 2022 in Education by JackTerrance
0 votes
    I have tried several ways but somehow they dont look clean; I have a URL file in Excel format (400+ urls in a ... easy way to do it? Select the correct answer from above options...
asked Feb 1, 2022 in Education by JackTerrance
0 votes
    I am trying to do some validation on the file name before it's saved. Here are my three file- ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 14, 2022 in Education by JackTerrance
0 votes
    I am trying to export p-values to Excel from the Stata community-contributed command reghdfe: // get data ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 24, 2022 in Education by JackTerrance
0 votes
    I have an issue where i want to import value from a textfile into my excel-document which it does ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 20, 2022 in Education by JackTerrance
0 votes
    I have 10 worksheets. I want to create a table for each. every table has a different amount of ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 2, 2022 in Education by JackTerrance
0 votes
    Below, I have code that sends a personalized SMS message and includes the name. I got that part to ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 17, 2022 in Education by JackTerrance
0 votes
    Below, I have code that sends a personalized SMS message and includes the name. I got that part to ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 13, 2022 in Education by JackTerrance
0 votes
    I have 10 worksheets. I want to create a table for each. every table has a different amount of ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 4, 2022 in Education by JackTerrance
...