VBA to Copy and Paste Rows if Condition is Met - Excel VBA Example by ExcelDestination

Excel Destination · 1.8M views · 2017 · 10:48

Open on YouTube

Python, Ruby & scripting languagesSoftware (other)Education & learningtutorial

Why Stack Overflow recommends it

Stack Overflow users link it when asking how to copy or move rows between sheets based on a cell value, usually because they built their code from the video and hit an error.

Recommended by 1 people across 1 different months, 2017 to 2023.

What it is

A roughly 11-minute Excel VBA tutorial from the Excel Destination channel showing how to loop through rows on one sheet and copy entire rows to another sheet when a cell meets a condition. It uses a For loop with an If statement and is meant to be wired to a command button click event.

What people said

Recommends melp · 2018-12 · Stack Overflow · on “Insert Table header Row when column value changes”

To get started I suggest you search google "creating vba macros read and write column" Are you familiar with VBA macro? If not, you could use a combination of index, and match formula. Otherwise VBA solution logic, in VBA editor - which is accessible by Alt +F11: Click on the sheet you want your VBA code to apply to and start writing your function. For example a function to check a cell range called "myFunction" would be as follows, A single example: Sub myFunction () If range.("A1").value = "Customer1" then Range("B1:E1").Insert([Shift], [CopyOrigin]) end If Sub End More work required to check condition on event, dynamic insert, and will need to be wrapped in a loop. The below are tutorials

Cites Carl Visagie · 2017-08 · Stack Overflow · on “LibreOffice BASIC function - Copy if over a value to a new sheet”

I have tried many different ways to do this, but i think the fault is on my lack of knowledge. I Tried a few VBA methods, but i think my fault lies in the fact that this is LibreOffice Basic and all the ones I have been trying are for Excel. I dont know what the correct Syntax or objects are for LO Basic. [LINK] [this video] [LINK]

Cites Iris Anastacio · 2018-02 · Stack Overflow · on “Copy Row if criteria is met to a new sheet”

I am trying to copy and paste rows into a new sheet if the criteria is met. I have the code and it somewhat works. It copies any row in column "N" if it has "FEH" and pastes into a new worksheet labeled "FEH." However, each time it copies and pastes the row into the new worksheet it opens up a dialog box that says "Updating Values: Name of folder where workbook is saved" The box looks like a save as dialog box. I have to click cancel or close out of it each and every time (I have included a picture of the dialog box). I found this code from a youtube channel: [this video] I removed two lines that he is using because if I leave those lines the code doesn't stop running. What do I have to fix in or

Cites Jorge M · 2018-07 · Stack Overflow · on “VBA Creating new sheets from unique column values in Sheet1 + bringing over adjacent row information”

VBA Creating new sheets from unique column values in Sheet1 + bringing over adjacent row information Hey all- I'm trying to a script that identifies the unique values in column E (data starts on row 1), creates a new sheet based on those unique values (also names the sheet per the value), and in the new sheet it creates it brings over the information corresponding rows in column A, C, D, and H - I found this YouTube video that shows the process but instead of the script indentifying the unique values you have to manually input the keyword it is looking for and it only runs it once. I haven't been able to get the 'for loop' to run properly ... [this video] Any help would be much appreciated-! Priv

Cites Mstemployment · 2020-06 · Stack Overflow · on “Using VBA to cause my command button to transfer rows to second sheet dependent on dropdown in column B”

I am completely new to VBA, but it appears to do what I need it to do. I have created a sheet with 68 rows of values. The next column, a user will select from a drop down of 4 variables. The command button will cause all selections from column A that were identified as "very important" in Column B to the next sheet for further use in decision making. I am following the process that is used in the following video, as it is doing exactly what I am looking for, for this step. [this video] However, when I do the Msgbox (a) to check that is working, I get Run time error "1004" Application-defined or object-defined error. I can't figure out what I am doing wrong.

Cites Hajoroeters · 2023-11 · Stack Overflow · on “Copy specific rows based on text in a specific column to a different sheet”

I am currently tryinig to hardcopy data from one sheet1 (Output for Exact) to a different sheet2 (Hard Output Accruals). Column I in both sheets provides a description that can be either Mark-up or Accrual . My goal is to hard copy all rows from sheet1 to sheet2 where Column I indicates an Accrual. However, when I try to run my code, it does not work (select method of range class failed). Any suggestions? PS. the code is based on the following tutorial: [this video] Kind regards, Hajo Here is the code: Sub Coentunnel_Accruals() ' Coentunnel Macro If Worksheets("Checks").Range("C2").Value > 0.01 Then MsgBox "One or multiple checks is/are invalid" Exit Sub End If a = Worksheets("Output for Exact").