VBA problem repeat task for each colum?
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 cell 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 :confused -- Message posted from http://www.ExcelForum.com |
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 :confused: --- Message posted from http://www.ExcelForum.com/ |
All times are GMT +1. The time now is 08:42 PM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com