Excel VBA set multiple cells to the same value

前端 未结 4 1218
栀梦
栀梦 2021-01-05 03:04

I want to set every eighth cell on one worksheet to the value of a cell in another worksheet. I wrote this here:

Sub xx()
    For i = 5 To 45 Step 8
                 


        
4条回答
  •  执笔经年
    2021-01-05 03:33

    If you are just trying to set the value of one cell to another in this way, you don't need to use the Set property - which is for objects not values.

    Also ThisWorkbook refers to where the macro is held, but is not suited to calling in this way.

    As such, I'd give: ActiveWorkbook.Sheets("Sheet5").Cells(i, 3).Value = ActiveWorkbook.Sheets("Sheet7").Cells(13, 31).Value

    a go, as this works fine for me.

提交回复
热议问题