How to add IF qualifier to code?

LlebKcir

Board Regular
Joined
Oct 8, 2018
Messages
219
I am copying and pasting data from one worksheet to another and I would like to add an IF qualifying statement to the loop

If cell = FALSE paste, else skip. that is what i am after.

VBA Code:
        j = 2       ' Reset j back to 2.
                    ' Sets starting point for copy/paste of data to correct Cell.
                    Set rFoundCell = Worksheets("overview").Range("A1")

               ' Starts for loop to search for 'start' vaule on the Overview Worksheet in the Protector Type column.
               For lCount = 1 To Application.WorksheetFunction.CountIf(Worksheets("overview").Range("a1:a200"), start)
               ' Finds the 'start' value on the Overview Worksheet in the Protector Type column.
               Set rFoundCell = Worksheets("overview").Columns(1).Find(what:=start, after:=rFoundCell, LookIn:=xlValues, lookat:=xlPart, searchorder:=xlByRows, searchdirection:=xlNext, MatchCase:=False)

                     ' Start of the copy/paste data from Overview to new Group # Worksheet in a transpose form.
                     With rFoundCell
                         ' The offset will move the source from column A to column E, column count -1 = number below.  A = 0, B = 1, C = 2, etc...
                         Worksheets("overview").Range(rFoundCell.Address).Offset(, 4).Copy
                         Worksheets("group " & start).Activate
                         '                           .Cells([row], [column]).       .Cells(32, j) moves down to Row 32.
                         Worksheets("group " & start).Cells(32, j).PasteSpecial xlPasteValues
                         j = j + 1
     
                     End With

               Next lCount

Thank you in advance for guidance and help.
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
Sorry to be a bit more clear:

Data to IF statement against:

TRUEFALSEFALSETRUE
FALSETRUETRUEFALSE
TRUETRUETRUEFALSE

Desired output:
FALSEFALSE
FALSEFALSE
FALSE

I hope that clears up what I am asking for a bit better.

Thank you
 
Upvote 0
Sorry the above example was a bit off. Yes the current copy/paste VB script performs a transpose on the data from one worksheet to the other, it should look as follows:
Input:
TRUE
FALSE
FALSE
TRUE
Output:
FALSEFALSE

I would like the IF qualifying statement to just iterate the count on the loop without copying any data from one worksheet to the other, and only have the copy/paste function run when FALSE is in the source field.

Is that possible?
 
Upvote 0

Forum statistics

Threads
1,214,872
Messages
6,122,025
Members
449,060
Latest member
LinusJE

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top