View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default VBA problem repeat task for each colum?

Private Sub CommandButton2_Click()
for i = 7 to 207
cells(i,"F").Value = cells(i,"F").Value + cells(i,"H").Value
cells(i,"H").Value = 0
Next
End Sub


or
Private Sub CommandButton2_Click()
Dim rng as Range
set rng = Range(cells(7,"F"),Cells(207,"F"))
rng.offset(0,2).Copy
rng.PasteSpecial xlPasteValues, _
xlPasteSpecialOperationAdd
rng.offset(0,2).Value = 0
End Sub

--
Regards,
Tom Ogilvy


"daveyscouse " wrote in message
...
Hi

This is my first posting here, well anywhere really.

Trying to teach myself all about VBA in my spare time

What I want to do is get the following command to repeat in the cells
below

ie row 8,9 ect to row 207

Private Sub CommandButton2_Click()

Dim rng As range
Set rng = Sheets("Dispensary").range("f7")
rng.Value = rng.Value + range("h7")
range("h7") = 0

End Sub

Probably really easy but cannot find how to do it anywhere.

Hope someone can help

Cheers Davey



---
Message posted from http://www.ExcelForum.com/