Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
Solved

# Additional Criteria to IF statement

Posted on 2014-01-13
Medium Priority
234 Views
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
``````

If all of the VBA is needed, please let me know.
0
Question by:jmac001
[X]
###### Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

• Help others & share knowledge
• Earn cash & points

LVL 43

Accepted Solution

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

ID: 39777715
Thanks much that worked
0

## Featured Post

Question has a verified solution.

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

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
After seeing numerous questions for Dynamic Data Validation I notice that most have used Visual Basic to solve the problem. This suggestion is purely formula based and can be used in multiple rows.
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
###### Suggested Courses
Course of the Month8 days, 13 hours left to enroll