If Statement with Multiple Criteria in Excel VBA

preview_player
Показать описание
Grab the Free VBA Quick Reference Guide
In this video we look at an If Then Statement that uses AND and OR for two criteria. And it is awesome :O)

Subscribe to get the latest videos
Рекомендации по теме
Комментарии
Автор

Jy there are a couple of ways to do this. I will typically use a do loop or for next loop to not send the highlighted data. The code would look something like this

Sub CopyFromSheet1toSheet2()

'This will copy from column A on Sheet1 to Sheet2 as long as there is not a blank cell
rw = 1
Do While Sheets("Sheet1").Cells(rw, 1) <> ""
If Sheets("Sheet1").Cells(rw, 1) = "Whaterver your Criteria is" Then
Sheets("Sheet2").Cells(rw, 1) = Sheets("Sheet1").Cells(rw, 1)
End If

rw = rw + 1
Loop

End Sub

EverydayVBAExcelTraining
Автор

Your voice is very low...but this is a good video

gullivergimeno
Автор

Epic man. Thanks! I will test it with text. Hope it will work. 

insane
Автор

How do I take that into a loop. Example: perform same logic but for all cells going down column B, not just a single cell ?

jeffreyghb
Автор

How do you compose an if function if there are multiple criteria and when do you know when to use the different options (if, then, else, elseif) ?

mariahclawson
Автор

URGENT.
I am working with multiple conditions to be satisfied simultaneously,



If f >= d And f <= e And S = "Y" And f1 >= d And f1 <= e And S1 = "Y" And arr1(i, 5) = arr2(j, 5) Then


my code works but takes a lot of time to process the data and give output.
What are the options for doing the same faster? I am already taking values from the Array. Please help.

adityakhare
Автор

Hi, i have created a macro to copy and paste data from Sheet 1 to Sheet 2 however i have set some rules in Sheet 1 to highlight erroneous values and i do not want these data to be copied to Sheet 2. Can you advice on the code to set this condition? Thanks alot in advance!

jylim
Автор

Hi, I'm trying to write and if function, for 1 page cost $2, but each additional page cost $.50, but I cant figure out to write the over the 1 page costing $.50 any help will be greatly appreciated, thanks

rafaeltejeda
Автор

What if you want to populate a cell based on the value of two other cells. If the value of cell A1, for exampls, is "AAA" AND the value of B1 is "BBB", how do I write the macro so as to go in Sheet 2, cell c1, for example, and take this value (of C1) and populate it in my initial sheet ?

harrinho
Автор

Hello. Maybe You can help me out with file renaming in multiple folders? The code for renaming files in "Master" folder I hawe, only want to update that it renaming files also in subfolders

janisrozentals