Solved

Copy value to another sheet when condition is met

Posted on 2014-03-24
3
848 Views
Last Modified: 2014-03-31
Can somebody help me with some VBA-code that loops through a range and copies the value in a cell to another sheet when condition is met.

Example:

Check if the value of cells A1:A10 = x, if yes copy the corresponding values from B1:B10 to another sheet

Best wishes
Lars
0
Comment
Question by:LarsDyrby
3 Comments
 
LVL 48

Expert Comment

by:Rgonzo1971
ID: 39950364
Hi,

Could you be more specific?

Sub macro()
For Each c In Range("A1:A10")
    If LCase(c) = "x" Then
        c.Offset(0, 1).Copy Destination:=Worksheets("Sheet3").Range("B" & Cells.Rows.Count).End(xlUp).Offset(1)
        c.EntireRow.Delete
    End If
Next
End Sub

Open in new window

Regards
0
 
LVL 31

Accepted Solution

by:
Rob Henson earned 500 total points
ID: 39950958
You can do this without VBA using the Advanced Filter feature.

To make a copy to another location, select that location before instigating the feature.

The destination sheet has to have the same column headers (or a selection of) as the source data.

Thanks
Rob H
0
 

Author Closing Comment

by:LarsDyrby
ID: 39967183
Used the advanced filter

Thx to Rob
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Workbook link problems after copying tabs to a new workbook? David Miller (dlmille) Intro Have you either copied sheets to a new workbook, and after having saved and opened that workbook, you find that there are links back to the original sou…
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
Viewers will learn the basics of slicers and timelines for both PivotTables and standard Excel tables in Excel 2013.
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now