'VBA Excel change column inside of formula

I have a formula within a loop.

For x = 0 To dataLastColumn - 1
    wsModel.Cells(startCell + 3, 2 + x).Formula = "=(($B$34*B33)/B30)*B31"
Next x

For each x I'd like to change the column for the next one. For example: if x = 1 than my desired formula would be -

wsModel.Cells(startCell + 3, 2 + 1).Formula = "=(($B$34*C33)/C30)*C31"

if x = 2

wsModel.Cells(startCell + 3, 2 + 2).Formula = "=(($B$34*D33)/D30)*D31"

Is there a way to change columns like that?



Solution 1:[1]

I Try This One Its Working

sModel.Cells(startCell + 3, 2 + x).Resize(, dataLastColumn-1).Formula = "=(($B$34*B33)/B30)*B31"

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Jahanzaib Sehar