Question

I want to create a loop for the following code . The only thing i need the to loop to do is move to the next column (which would be column F). the rows will stay the same. any suggestions?

xlSheet.Range("e23") = (Me.overrings)
xlSheet.Range("e33") = (Me.overingTax)
xlSheet.Range("e27") = (Me.Sampling)
xlSheet.Range("e28") = (Me.Waste)
xlSheet.Range("e29") = (Me.Promo)
xlSheet.Range("e42") = (Me.Online)
xlSheet.Range("e34") = (Me.freebieTax)
xlSheet.Range("e49") = (Me.totalDepo)
xlSheet.Range("e38") = (Me.CreditCards)
Was it helpful?

Solution

For x= 5 to 6
With xlSheet.columns(x)
   .cells(23).value=Me.overrings
   'etc 
End with
Next x

OTHER TIPS

If you really want the same value in the adjacent cell, you can modify your existing code like this (no loop required):

xlSheet.Range("e23:f23") = (Me.overrings)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top