Excel VBA set multiple cells to the same value

前端 未结 4 1257
栀梦
栀梦 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:56

    The issue seemed to be that you had an end if without a corresponding If to start, and to assign a value for the range in sheet 5 you don't need to state set you can just assign the values directly like so:

    Sub xx()
    For i = 5 To 45 Step 8
    ActiveWorkbook.Sheets("Sheet5").Cells(i, 3).Value = ActiveWorkbook.Sheets("Sheet7").Cells(13, 31).Value
    Next i
    End Sub
    

提交回复
热议问题