Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Additional Criteria to IF statement

Posted on 2014-01-13
2
Medium Priority
?
239 Views
Last Modified: 2014-01-13
I have VBA that opens a file and copies data over based on name in column A.  How would I update the statement to look at criteria in column A (Vxxxxxxx) and Column C (Axxxxxx)? I try to update but couldn't get the right combination.


Here is the part of the code with the if statement

   For I = 2 To lastSourceCell.Row
            If ws.Range("A" & I).Value = "Vxxxxxxx" Then
                ws.Range("A" & I).EntireRow.Copy
                ThisWorkbook.Sheets("ISS").Range("A" & destinationRow).PasteSpecial xlPasteAll
                destinationRow = destinationRow + 1
            End If
        Next

Open in new window


If all of the VBA is needed, please let me know.
0
Comment
Question by:jmac001
2 Comments
 
LVL 43

Accepted Solution

by:
Saqib Husain, Syed earned 2000 total points
ID: 39777669
Try

If ws.Range("A" & I).Value = "Vxxxxxxx" and ws.Range("C" & I).Value = "Axxxxxxx" Then
0
 

Author Closing Comment

by:jmac001
ID: 39777715
Thanks much that worked
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

How to get Spreadsheet Compare 2016 working with the 64 bit version of Office 2016
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

885 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