RE: VBA If statement to select row copy row to another cell

BIGTONE559

Active Member
Joined
Apr 20, 2011
Messages
336
RE: VBA If statement to select row copy row to another cell

Greetings,

I'm new to vba and i'm running into inssues with the following:

I've set up a module and it:
1. Creates a Sluggish environment throughout excel
2. My setup does not find the actual cells with the conditions that i've identified.

I would appreciate any assistance.

Code:
Sub Test()

Dim x As Integer
Dim y As Integer
Dim z As Integer




x = 5
y = 5
z = 5




Application.ScreenUpdating = False

Range("J5:Z10000").ClearContents

If Cells(x, 7).Value <> "Yes" Then





Do Until x = 16
Range(Cells(x, 1), Cells(x, 5)).Select
Selection.Copy
Cells(y, 10).Select
ActiveSheet.Paste
Application.CutCopyMode = False


x = x + 1
y = y + 1



Loop
End If

Application.ScreenUpdating = True


End Sub
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
Re: VBA If statement to select row copy row to another cell

Try without selecting

Code:
Sub Test()

Dim x As Integer
Dim y As Integer
Dim z As Integer




x = 5
y = 5
z = 5




Application.ScreenUpdating = False

Range("J5:Z10000").ClearContents

If Cells(x, 7).Value <> "Yes" Then





Do Until x = 16
Range(Cells(x, 1), Cells(x, 5)).Copy Destination:=Cells(y, 10)


x = x + 1
y = y + 1



Loop
End If
Application.CutCopyMode = False

Application.ScreenUpdating = True


End Sub
 
Upvote 0
Re: VBA If statement to select row copy row to another cell

Thanks VOG

for some reason or another after i run the macro the speed in excel decreases horribly!!!!!!

Also with my if statement it isn't actually checking the value of the cell and limiting the results by the condition defined.

from row ranges 5-15 instead of 2 rows (which contain "yes") it selects all 11
 
Upvote 0
Re: VBA If statement to select row copy row to another cell

Is it copying and pasting formulas? If so you might want to use paste special instead.

It is only checking if G7 = Yes. Is that correct?
 
Upvote 0
Re: VBA If statement to select row copy row to another cell

Yes (At Least For now)

I've written conditional formatting that basically does what i will eventually want VBA to do. Hadn't made it that far yet.

G7 was basically checking if conditions we're true in F7 the are both as follows

G7=If(F7=True,"yes","no")
G7=IF(VLOOKUP(D7,DbMaster,2,FALSE)<>B7,TRUE,FALSE)

I will definitely want VBA to handle all off the calculations the only problem is i'm not familiar with VBA to do so.

I have 9320 rows of data on this sheet which references a Db of 241219

(i hope all this background info give you a greater understanding.)
 
Upvote 0
Re: VBA If statement to select row copy row to another cell

Try describing in words exactly what the code is meant to do.
 
Upvote 0
Re: VBA If statement to select row copy row to another cell

OK.. . . .

I have 2 worksheets that serve as Db.

1. My Db
2. Bank Db

I want to check against what the bank has and what i have.

I'm able to (not in vb) easily identify errors with the bank.

Now i would like to Copy the Rows (Which has data 1x5 long) then paste it in another column where a "Form" has been created.
 
Upvote 0
Re: VBA If statement to select row copy row to another cell

That isn't very descriptive.

Your code is only operating on the active (selected) sheet. Is that correct.
 
Upvote 0
Re: VBA If statement to select row copy row to another cell

My apologies VOG it isn't very descriptive. . . and yes all the code will be done on this page. it will however reference other pages. . .


the goal is to vlookup values on the current sheet and reference other page as frame of reference. . . if the value of the current sheet does not match my database then i would like to copy that record and paste it in a form that begins in cell "J5" in the current sheet.

Does that make more sense?

The "records" on the sheet in question are from Column A to column E the Column. The Records begin at row 2 and end at 9218
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,560
Messages
6,179,519
Members
452,921
Latest member
BBQKING

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