ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Copying a cell value to a specific cells (https://www.excelbanter.com/excel-programming/407744-copying-cell-value-specific-cells.html)

MJKelly

Copying a cell value to a specific cells
 
Hi,

I am looping through a range of cells looking for certain criteria.
When one is reached, I want to copy the value into the next 10 cells
in the same row as the active cell in the loop. I am trying to use
the offset property to do this but cannot get it to work. Is this the
right way to approach this?

kind regards,
Matt


FSt1

Copying a cell value to a specific cells
 
hi
would have been nice if you had posted your code.
but this sniplet does what you want. use it as an example.
Sub doit()
Dim r As Range
Set r = Range("A1:A10")
For Each cell In r
If cell = "x" Then 'find object
For y = 1 To 10
cell.Offset(0, y) = "x"
Next y
End If
Next cell
End Sub

regards
FSt1
"MJKelly" wrote:

Hi,

I am looping through a range of cells looking for certain criteria.
When one is reached, I want to copy the value into the next 10 cells
in the same row as the active cell in the loop. I am trying to use
the offset property to do this but cannot get it to work. Is this the
right way to approach this?

kind regards,
Matt




All times are GMT +1. The time now is 10:34 AM.

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