I'm new to to vbs script in excel, and i'm stuck on looping through column function. I have the function below it does what I want but it stop after one iteration. I want it to loop through entire range A1 until the cell is blank. Range A1 contain given numbers, and functions below that does the sum until it hit 100; once it get 100 total. The paste of functions right next to the cell of 100 continue until the end of range A1. The number of sum equal 100 is varies between 4 column and 6 column.
============================================
A B C D E F G H I J K
1 15 15 15 40 30 10 20 30 40 10 15
2 15 15 15 40 30 100 20 30 40 100
3 10 10 15 15 15 65
4 # # # # # #
5 # # # # # #
6
7
8
9 Reference Range of Formula to copy and paste
10 15 15 15 40 30 100
11 10 10 15 15 15 65
12 # # # # # #
13 # # # # # #
14
15
Thanks,
Fred
Moderators Note:
Code:
Sub TryMe()
Dim Rng As Range
With Worksheets("Sheet1")
Set Rng = .Range("A2")
If WorksheetFunction.CountA(Rng) = 0 Then
If Worksheets("Sheet1").Range("A1") <> "" Then
Worksheets("Sheet1").Range("A10:F14").Copy Destination:=Rng
End If
End If
End With
End Sub
A B C D E F G H I J K
1 15 15 15 40 30 10 20 30 40 10 15
2 15 15 15 40 30 100 20 30 40 100
3 10 10 15 15 15 65
4 # # # # # #
5 # # # # # #
6
7
8
9 Reference Range of Formula to copy and paste
10 15 15 15 40 30 100
11 10 10 15 15 15 65
12 # # # # # #
13 # # # # # #
14
15
Thanks,
Fred
Moderators Note:
- Please follow Forum Rule #3 and use code tags.
- Added for you this time, but please use them in the future…Thanks.