ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   If true, paste, then next cell (https://www.excelbanter.com/excel-discussion-misc-queries/102795-if-true-paste-then-next-cell.html)

[email protected]

If true, paste, then next cell
 
I am going around in circles trying to get this macro to work. I would
like it to see if the contents of a cell match a perameter. If so I
want it to paste a copied range of data into the cell, then check the
next cell until it either reached an empty cell.

Any suggestions?


Range("$AP$2:$DZ$2").Select
Selection.Copy

Dim rg1 As Range
Set rg1 = Range("AP12")

Do Until IsEmpty(rg1)
If rg1 = "2" Then
ActiveSheet.Paste
Else
Set rg1 = rg1.Offset(1, 0)

End If
Loop
End Sub



All times are GMT +1. The time now is 02:25 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com