Excel VBA copy and paste loop with logic condition
Solved/Closed
Yogibearv
Posts
2
Registration date
Monday October 20, 2014
Status
Member
Last seen
October 21, 2014
-
Updated on Jan 30, 2019 at 08:33 AM
Yogibearv - Oct 28, 2014 at 04:27 PM
Yogibearv - Oct 28, 2014 at 04:27 PM
Hi,
I am new to VBA and would appreciate some help with a problem I am trying to solve.
I would like a macro that is able to copy information from a cell (in this case I7) into another on the same worksheet (B7). I then would like the macro to check what is written in Cell D5, If the value is "NO", then copy I8 to B8 and so on (offset by one row). When D5 changes to "OK" I would like the macro to stop.
Many thanks in advance!
I am new to VBA and would appreciate some help with a problem I am trying to solve.
I would like a macro that is able to copy information from a cell (in this case I7) into another on the same worksheet (B7). I then would like the macro to check what is written in Cell D5, If the value is "NO", then copy I8 to B8 and so on (offset by one row). When D5 changes to "OK" I would like the macro to stop.
Many thanks in advance!
Related:
- Vba to copy and paste a range multiple times based on cell value
- Copy paste loop vba - Best answers
- How to copy cell if condition is met and paste in another cell - Best answers
- Based on the cell values in cells b77 ✓ - Excel Forum
- Discord invisible name copy and paste ✓ - Internet & Social Networks Forum
- How to insert rows in excel automatically based on cell value without vba ✓ - Excel Forum
- Why cant i copy and paste on instagram ✓ - Instagram Forum
- Vba case like - Guide
4 responses
TrowaD
Posts
2921
Registration date
Sunday September 12, 2010
Status
Moderator
Last seen
December 27, 2022
555
Oct 28, 2014 at 12:19 PM
Oct 28, 2014 at 12:19 PM
Hi Yogibearv,
So you use a formula for D5, that makes more sense. Try this code:
Best regards,
Trowa
So you use a formula for D5, that makes more sense. Try this code:
Sub RunMe() Dim lRow, x As Integer lRow = Range("I" & Rows.Count).End(xlUp).Row x = 6 Do x = x + 1 Range("B" & x).Value = Range("I" & x).Value Range("I" & x).ClearContents Loop Until IsEmpty(Range("I" & x + 1)) Or x = lRow Or Range("D5").Value = "OK" End Sub
Best regards,
Trowa